edit.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  1. <template>
  2. <div>
  3. <Toptitle :title="$route.query.type==1?'新增入库单':$route.query.type==2?'查看入库单':'编辑入库单'">
  4. <slot name="titleButton">
  5. <Button @click="handleReference(5,1)"
  6. type="primary"
  7. ghost
  8. style="margin-right:10px;"
  9. v-show="!isCheck"
  10. :disabled='$route.query.is_refer == 0?true:btn1_disable'>参照采购单</Button>
  11. <Button @click="handleReference(6,2)"
  12. type="primary"
  13. ghost
  14. style="margin-right:10px;"
  15. v-show="!isCheck"
  16. :disabled="$route.query.is_refer == 0?true:btn2_disable">参照到货单</Button>
  17. <Button @click="handleReference(7,3)"
  18. type="primary"
  19. ghost
  20. style="margin-right:10px;"
  21. v-show="!isCheck"
  22. :disabled="$route.query.is_refer == 0?true:btn3_disable">参照质检单</Button>
  23. <Button @click="goBack"
  24. type="primary"
  25. ghost
  26. style="margin-right:10px;">返回</Button>
  27. <Button @click="postData"
  28. type="primary"
  29. ghost
  30. v-show="!isCheck"
  31. style="margin-right:10px;">确定</Button>
  32. </slot>
  33. </Toptitle>
  34. <div class="content_topform">
  35. <Form :label-width="90"
  36. :model="searchData">
  37. <FormItem label="项目名称:">
  38. <Input type="text"
  39. size="small"
  40. v-model="searchData.residential_name"
  41. v-show="!isCheck"
  42. style="width: 200px;margin-top:6px"
  43. placeholder="项目名称">
  44. <span slot="append"
  45. style="cursor:pointer;"
  46. @click="showProjectModal=true">选择</span>
  47. </Input>
  48. <span v-show="isCheck">{{searchData.residential_name}}</span>
  49. </FormItem>
  50. <FormItem label="供应商名称:">
  51. <Input type="text"
  52. size="small"
  53. v-model="searchData.supply_title"
  54. style="width: 200px;margin-top:6px"
  55. v-show="!isCheck"
  56. placeholder="供应商名称">
  57. <span slot="append"
  58. style="cursor:pointer;"
  59. @click="showSupplierModal=true">选择</span>
  60. </Input>
  61. <span v-show="isCheck">{{searchData.supply_title}}</span>
  62. </FormItem>
  63. <FormItem label="仓库:">
  64. <Select v-model="searchData.warehouse_id"
  65. size="small"
  66. clearable
  67. filterable
  68. label-in-value
  69. v-show="!isCheck"
  70. style="width: 200px">
  71. <Option v-for="(sitem) in warehouseList"
  72. :key="sitem.id"
  73. :label="sitem.title"
  74. :value="sitem.id">
  75. </Option>
  76. </Select>
  77. <span v-show="isCheck">{{searchData.warehouse_title}}</span>
  78. </FormItem>
  79. <FormItem label="单据号:">
  80. <Input type="text"
  81. size="small"
  82. readonly
  83. v-show="!isCheck"
  84. v-model="searchData.order_in_no"
  85. style="width: 200px"
  86. placeholder="自动生成" />
  87. <span v-show="isCheck">{{searchData.order_in_no}}</span>
  88. </FormItem>
  89. <FormItem label="入库类型:">
  90. <Select v-model="searchData.type_id"
  91. size="small"
  92. clearable
  93. filterable
  94. v-show="!isCheck"
  95. label-in-value
  96. style="width: 200px">
  97. <Option v-for="(sitem) in purchaseTypeList"
  98. :key="sitem.id"
  99. :label="sitem.title"
  100. :value="sitem.id">
  101. </Option>
  102. </Select>
  103. <span v-show="isCheck">{{searchData.type_id == 1 ?'采购入库':'库存入库'}}</span>
  104. </FormItem>
  105. <!-- <FormItem label="制单人:">
  106. <Input type="text"
  107. size="small"
  108. v-model="searchData.nickname"
  109. style="width: 200px"
  110. placeholder="制单人" />
  111. </FormItem> -->
  112. <FormItem label="制单日期:">
  113. <DatePicker type="date"
  114. size="small"
  115. style="width: 200px"
  116. v-show="!isCheck"
  117. placeholder="年/月/日"
  118. v-model="searchData.crt_time"></DatePicker>
  119. <span v-show="isCheck">{{func.replaceDate(searchData.crt_time)}}</span>
  120. </FormItem>
  121. <FormItem label="备注:">
  122. <Input type="textarea"
  123. size="small"
  124. v-model="searchData.remark"
  125. v-show="!isCheck"
  126. style="width: 200px"
  127. placeholder="备注" />
  128. <span v-show="isCheck">{{searchData.remark}}</span>
  129. </FormItem>
  130. </Form>
  131. </div>
  132. <div class="content_table">
  133. <div class="content_table_btn">
  134. <div>
  135. <span>入库清单</span>
  136. <Button @click="showModal=true"
  137. type="primary"
  138. size="small"
  139. style="margin-left:10px;"
  140. v-show="!isCheck"
  141. :disabled="$route.query.is_refer == 1?true:btn_disable">选择物料</Button>
  142. </div>
  143. <div class="content_table_btn_right">
  144. </div>
  145. </div>
  146. <Table :columns="tableColumns"
  147. border
  148. :data="tableData"
  149. show-summary :summary-method="handleSummary"
  150. >
  151. <template slot="numberSet" slot-scope="{row , index }">
  152. <Tooltip
  153. placement="left"
  154. @on-popper-show="handleToolShow(index, row)"
  155. >
  156. <div slot="content">
  157. <div>
  158. <div v-for="(_item,_index) in warehouse" :key="_index">
  159. {{_item.warehouse_title}}:{{_item.num}}
  160. </div>
  161. </div>
  162. </div>
  163. <Input
  164. type="text"
  165. v-show="!isCheck"
  166. size="small"
  167. v-model="tableData[index].num"
  168. placeholder="数量"
  169. >
  170. </Input>
  171. <span v-show="isCheck">{{ tableData[index].num }}</span>
  172. </Tooltip>
  173. </template>
  174. <template slot="setSlot"
  175. slot-scope="{row,index}">
  176. <a style="margin:0 5px"
  177. :disabled="row.state==0"
  178. @click="handleSet(4,row,index)">删除</a>
  179. </template>
  180. </Table>
  181. </div>
  182. <Modal v-model="showModal"
  183. title="选择物料"
  184. width='80'
  185. @on-ok="handleSelect"
  186. @on-cancel="showModal=false">
  187. <div class="modal_content">
  188. <div class="modal_content_left">
  189. <Tree :data="modalData.treeData"
  190. children-key='list'
  191. style="width:100%;"
  192. @on-select-change="handleTreeSlect"
  193. class="demo-tree-render"></Tree>
  194. </div>
  195. <div class="modal_content_center">
  196. <div class="modal_content_center_top">
  197. <div><span>物料名称:</span>
  198. <Input type="text"
  199. v-model="modalData.title"
  200. placeholder="请输入物料名称" />
  201. </div>
  202. <Button @click="initModal()"
  203. type="primary"
  204. style="margin:0 10px;">搜索</Button>
  205. </div>
  206. <div class="modal_content_center_body">
  207. <Table :columns="modalTableColumns"
  208. height="520"
  209. border
  210. ref="modelTable"
  211. @on-select-all="handleSelectionAll"
  212. @on-select-all-cancel="handleSelectionAllCancel"
  213. @on-select="handleSelection"
  214. @on-select-cancel="handleSelectionCancel"
  215. :loading="modalTableLoading"
  216. :data="modalData.tableData">
  217. </Table>
  218. <div class="modal_content_center_footer">
  219. <Page :page-size-opts="[10, 20, 30, 40,100]"
  220. @on-page-size-change='changeModalSize'
  221. @on-change='changeModalPage'
  222. :current='modal_page_index'
  223. show-total
  224. :total="modal_total"
  225. show-sizer
  226. :page-size='modal_page_size' />
  227. </div>
  228. </div>
  229. </div>
  230. <div class="modal_content_right">
  231. <span>已选</span>
  232. <Table :columns="selectedColumns"
  233. max-height="500"
  234. border
  235. :data="modalData.selectedData">
  236. <template slot="selectedSetSlot"
  237. slot-scope="{row,index}">
  238. <a style="margin:0 5px;color:red"
  239. @click="handleSelectedDele(row,index)">删除</a>
  240. </template>
  241. </Table>
  242. </div>
  243. </div>
  244. </Modal>
  245. <Modal v-model="showProjectModal"
  246. title="选择项目"
  247. width='80'
  248. @on-ok="handleProjectSelect"
  249. @on-cancel="showProjectModal=false">
  250. <div class="modal_content">
  251. <div class="modal_content_center">
  252. <div class="modal_content_center_top">
  253. <span>项目名称:</span>
  254. <Input type="text"
  255. v-model="modalProjectData.title"
  256. style="width:180px"
  257. placeholder="请输入物料名称" />
  258. <Button @click="initProjectModal()"
  259. type="primary"
  260. style="margin:0 10px;">搜索</Button>
  261. </div>
  262. <div class="modal_content_center_body">
  263. <Table :columns="modalProjectTableColumns"
  264. height="520"
  265. border
  266. :loading="modalProjectTableLoading"
  267. :data="modalProjectData.tableData">
  268. <template slot="basicTypeSet"
  269. slot-scope="{row}">
  270. <div>
  271. <span v-for="item in warningList"
  272. :key="item.id"
  273. :style="{color:item.color}"
  274. v-show="item.id==row.warning_state">{{item.title}}</span>
  275. </div>
  276. </template>
  277. </Table>
  278. <div class="modal_content_center_footer">
  279. <Page :page-size-opts="[10, 20, 30, 40,100]"
  280. @on-page-size-change='changeProjectModalSize'
  281. @on-change='changeProjectModalPage'
  282. :current='modal_project_page_index'
  283. show-total
  284. :total="modal_project_total"
  285. show-sizer
  286. :page-size='modal_project_page_size' />
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. </Modal>
  292. <Modal v-model="showSupplierModal"
  293. title="选择供应商"
  294. width='80'
  295. @on-ok="handleSupplierSelect"
  296. @on-cancel="showSupplierModal=false">
  297. <div class="modal_content">
  298. <div class="modal_content_left">
  299. <Tree :data="modalSupplierData.treeData"
  300. children-key='sub'
  301. style="width:100%;"
  302. @on-select-change="handleSupplierTreeSlect"
  303. class="demo-tree-render"></Tree>
  304. </div>
  305. <div class="modal_content_center">
  306. <div class="modal_content_center_top">
  307. <span>供应商名称:</span>
  308. <Input type="text"
  309. v-model="modalSupplierData.title"
  310. style="width:180px"
  311. placeholder="请输入供应商名称" />
  312. <Button @click="initSupplierModal(modalSupplierData)"
  313. type="primary"
  314. style="margin:0 10px;">搜索</Button>
  315. </div>
  316. <div class="modal_content_center_body">
  317. <Table :columns="modalSupplierTableColumns"
  318. height="520"
  319. border
  320. :loading="modalSupplierTableLoading"
  321. :data="modalSupplierData.tableData">
  322. </Table>
  323. <div class="modal_content_center_footer">
  324. <Page :page-size-opts="[10, 20, 30, 40,100]"
  325. @on-page-size-change='changeSupplierModalSize'
  326. @on-change='changeSupplierModalPage'
  327. :current='modal_supplier_page_index'
  328. show-total
  329. :total="modal_supplier_total"
  330. show-sizer
  331. :page-size='modal_supplier_page_size' />
  332. </div>
  333. </div>
  334. </div>
  335. </div>
  336. </Modal>
  337. </div>
  338. </template>
  339. <script>
  340. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  341. // 例如:import 《组件名称》 from '《组件路径》';
  342. export default {
  343. name: '',
  344. components: {
  345. },
  346. props: {},
  347. // import引入的组件需要注入到对象中才能使用
  348. data () {
  349. // 这里存放数据
  350. return {
  351. isCheck:false,
  352. btn1_disable:false,
  353. btn_disable:false,
  354. btn2_disable:false,
  355. btn3_disable:false,
  356. fax_modify: '',
  357. searchData: {
  358. residential_name: ''
  359. },
  360. modalProjectData: {
  361. title: '',
  362. tableData: [{}]
  363. },
  364. modalSupplierData: {
  365. title: '',
  366. code: '',
  367. treeData: [
  368. {
  369. title: '供应商分类',
  370. expand: true,
  371. sub: [],
  372. render: (h, { root, node, data }) => {
  373. return h('span', {
  374. style: {
  375. display: 'inline-block',
  376. width: '100%'
  377. }
  378. }, [
  379. h('span', [
  380. h('Icon', {
  381. props: {
  382. type: 'ios-folder-outline'
  383. },
  384. style: {
  385. marginRight: '8px'
  386. }
  387. }),
  388. h('span', data.title)
  389. ]),
  390. h('span', {
  391. style: {
  392. display: 'inline-block',
  393. // float: 'right',
  394. marginRight: '32px'
  395. }
  396. })
  397. ]);
  398. },
  399. }
  400. ],
  401. tableData: [{}]
  402. },
  403. tableColumns: [
  404. { title: '物料分类', key: 'type_title', align: 'center', minWidth: 140 },
  405. { title: '物料名称', key: 'title', align: 'center', minWidth: 140 },
  406. {
  407. title: '物料规格', key: '', align: 'center', minWidth: 140,
  408. render: (h, params) => {
  409. const { row } = params
  410. let text = `${row.long ? row.long : 0}*${row.width ? row.width : 0}*${row.high ? row.high : 0}`
  411. return h('span', {}, text)
  412. }
  413. },
  414. { title: '计量单位', key: 'unit', align: 'center', minWidth: 100 },
  415. {
  416. title: '数量', key: 'num', align: 'center', minWidth: 120,slot:"numberSet"
  417. // render: (h, params) => {
  418. // const { row, index } = params
  419. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  420. // return this.$route.query.type == 2 ? h('span', {}, currentRow.num)
  421. // : h('Input', {
  422. // props: {
  423. // value: currentRow.num,
  424. // type: 'text'
  425. // },
  426. // on: {
  427. // 'on-change': (e) => {
  428. // currentRow.num = e.target.value
  429. // // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  430. // // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  431. // // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  432. // this.tableData.splice(index, 1, currentRow);
  433. // }
  434. // }
  435. // })
  436. // }
  437. },
  438. {
  439. title: '单价', key: 'total_price', align: 'center', minWidth: 120,
  440. render: (h, params) => {
  441. const { row, index } = params
  442. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  443. return this.$route.query.type == 2 ? h('span', {}, currentRow.total_price)
  444. :
  445. h('Input', {
  446. props: {
  447. value: currentRow.total_price,
  448. type: 'text'
  449. },
  450. on: {
  451. 'on-change': (e) => {
  452. currentRow.total_price = e.target.value
  453. this.tableData.splice(index, 1, currentRow);
  454. }
  455. }
  456. })
  457. }
  458. },
  459. {
  460. title: "金额", key: "total", align: "center", minWidth: 100,
  461. render: (h, params) => {
  462. const { row, index } = params;
  463. const currentRow = JSON.parse(
  464. JSON.stringify(this.tableData[index])
  465. );
  466. return h("span", {},currentRow.total_price&&currentRow.num?currentRow.total_price*currentRow.num:0)
  467. }
  468. },
  469. { title: '操作', key: 'code', align: 'center', minWidth: 100, slot: 'setSlot' },
  470. ],
  471. is_refer:'',
  472. tableData: [],
  473. showModal: false,
  474. showProjectModal: false,
  475. showSupplierModal: false,
  476. modalTableLoading: false,
  477. modalProjectTableLoading: false,
  478. modalSupplierTableLoading: false,
  479. modal_project_page_index: 1,
  480. modal_project_page_size: 10,
  481. modal_project_total: 0,
  482. modal_supplier_page_index: 1,
  483. modal_supplier_page_size: 10,
  484. modal_supplier_total: 0,
  485. currentChoose: {},
  486. modalProjectTableColumns: [
  487. {
  488. title: '选择', key: '', align: 'center', minWidth: 60,
  489. render: (h, params) => {
  490. let id = params.row.id;
  491. let flag = false;
  492. if (this.currentChoose.id == id) {
  493. flag = true
  494. } else {
  495. flag = false
  496. }
  497. let self = this
  498. return h('div', [
  499. h('Radio', {
  500. props: {
  501. value: flag
  502. },
  503. on: {
  504. 'on-change': () => {
  505. self.currentChoose = params.row;
  506. }
  507. }
  508. })
  509. ])
  510. }
  511. },
  512. { title: '项目名称', key: 'residential_name', align: 'center', minWidth: 100 },
  513. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 80, slot: 'basicTypeSet', },
  514. {
  515. title: '创建时间', key: 'crt_time', align: 'center', minWidth: 110,
  516. render: (h, params) => {
  517. const { row } = params
  518. return h('span', {}, this.func.replaceDate(row.crt_time))
  519. }
  520. },
  521. ],
  522. modalSupplierTableColumns: [
  523. {
  524. title: '选择', key: '', align: 'center', minWidth: 60,
  525. render: (h, params) => {
  526. let id = params.row.id;
  527. let flag = false;
  528. if (this.currentChoose.id == id) {
  529. flag = true
  530. } else {
  531. flag = false
  532. }
  533. let self = this
  534. return h('div', [
  535. h('Radio', {
  536. props: {
  537. value: flag
  538. },
  539. on: {
  540. 'on-change': () => {
  541. self.currentChoose = params.row;
  542. }
  543. }
  544. })
  545. ])
  546. }
  547. },
  548. { title: '供应商编码', key: 'code', align: 'center', minWidth: 100 },
  549. { title: '供应商名称', key: 'title', align: 'center', minWidth: 80, },
  550. { title: '负责人', key: 'contact', align: 'center', minWidth: 110, },
  551. { title: '联系方式', key: 'mobile', align: 'center', minWidth: 110, },
  552. ],
  553. modalData: {
  554. title: '',
  555. tableData: [{}],
  556. selectedData: [],
  557. treeData: [
  558. {
  559. title: '物料分类',
  560. expand: true,
  561. list: [],
  562. render: (h, { root, node, data }) => {
  563. return h('span', {
  564. style: {
  565. display: 'inline-block',
  566. width: '100%'
  567. }
  568. }, [
  569. h('span', [
  570. h('Icon', {
  571. props: {
  572. type: 'ios-folder-outline'
  573. },
  574. style: {
  575. marginRight: '8px'
  576. }
  577. }),
  578. h('span', data.title)
  579. ]),
  580. h('span', {
  581. style: {
  582. display: 'inline-block',
  583. // float: 'right',
  584. marginRight: '32px'
  585. }
  586. })
  587. ]);
  588. },
  589. }
  590. ],
  591. },
  592. selectedColumns: [
  593. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  594. { title: '操作', key: 'title', align: 'center', minWidth: 90, slot: 'selectedSetSlot' },
  595. ],
  596. modal_page_index: 1,
  597. modal_page_size: 10,
  598. modal_total: 0,
  599. modalTableColumns: [
  600. { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  601. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  602. { title: '物料规格', key: 'model', align: 'center', minWidth: 110 },
  603. { title: '计量单位', key: 'unit', align: 'center', minWidth: 110 },
  604. ],
  605. warehouseList: [],
  606. purchaseTypeList: [],
  607. warningList: [],
  608. warehouse:'',
  609. }
  610. },
  611. // 生命周期 - 创建完成(可以访问当前this实例)
  612. created () {
  613. this.$route.query.type == 2
  614. ? (this.isCheck = true)
  615. : (this.isCheck = false);
  616. // 获取采购类型
  617. this.axios({ method: 'get', url: '/api/basic_order_in_list', }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
  618. // 获取基础物料类型
  619. this.axios({ method: 'get', url: '/api/basics_material_index_level', }).then((res) => { this.modalData.treeData[0].list = res.data }).catch((err) => { });
  620. // 获取仓库列表
  621. this.axios({ method: 'get', url: '/api/warehouse', }).then((res) => { this.warehouseList = res.data }).catch((err) => { });
  622. // 获取供应商列表
  623. this.axios({ method: 'get', url: '/api/supply_list', }).then((res) => { this.suppliersList = res.data.data }).catch((err) => { });
  624. // 获取供应商分类
  625. this.axios({ method: 'get', url: '/api/basic_supply_list', }).then((res) => { this.modalSupplierData.treeData[0].sub = res.data }).catch((err) => { });
  626. // 获取项目列表
  627. this.axios({ method: 'get', url: '/api/order_index', }).then((res) => {
  628. this.modalProjectData.tableData = res.data.data
  629. this.modal_project_total = res.data.total
  630. }).catch((err) => { });
  631. // 获取紧急程度
  632. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  633. this.initModal()
  634. this.initProjectModal()
  635. this.initSupplierModal(this.modalSupplierData)
  636. },
  637. // 生命周期 - 挂载完成(可以访问DOM元素)
  638. mounted () {
  639. if (this.$route.query.order_in_no != '') {
  640. this.initData(this.$route.query.order_in_no)
  641. }
  642. },
  643. methods: {
  644. handleToolShow(index, row) {
  645. if (this.warehouse) {
  646. return
  647. } else {
  648. this.axios
  649. .get("/api/warehouse_stock_number", {
  650. params: {
  651. material_id: row.material_id,
  652. material_detail_id: row.material_detail_id,
  653. },
  654. })
  655. .then((res) => {
  656. this.warehouse= res.data
  657. });
  658. }
  659. // this.warehouse.num = this.warehouseTotal[index].num;
  660. // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
  661. },
  662. handleSummary ({ columns, data }) {
  663. const sums = {};
  664. columns.forEach((column, index) => {
  665. const key = column.key;
  666. if (index === 0) {
  667. sums[key] = {
  668. key,
  669. value: '总价'
  670. };
  671. return;
  672. }
  673. let val = data;
  674. for(let i in val){
  675. val[i].total = val[i].total_price*val[i].num;
  676. }
  677. const values = val.map(item => Number(item[key]));
  678. if (index === 6) {
  679. const v = values.reduce((prev, curr) => {
  680. const value = Number(curr);
  681. if (!isNaN(value)) {
  682. return prev + curr;
  683. } else {
  684. return prev;
  685. }
  686. }, 0);
  687. sums[key] = {
  688. key,
  689. value: v
  690. };
  691. }else if(index===4){
  692. const v = values.reduce((prev, curr) => {
  693. const value = Number(curr);
  694. if (!isNaN(value)) {
  695. return prev + curr;
  696. } else {
  697. return prev;
  698. }
  699. }, 0);
  700. sums[key] = {
  701. key,
  702. value: v
  703. };
  704. }
  705. else {
  706. sums[key] = {
  707. key,
  708. value: ''
  709. };
  710. }
  711. });
  712. return sums;
  713. },
  714. initData (order_in_no) {
  715. this.axios({
  716. method: 'get',
  717. url: '/api/warehouse_order_in_detail',
  718. params: { order_in_no }
  719. }).then((res) => {
  720. this.tableData = res.data.list
  721. const data = JSON.parse(JSON.stringify(res.data))
  722. delete data.list
  723. this.searchData = data
  724. console.log(this.searchData)
  725. }).catch((err) => { });
  726. },
  727. postData () {
  728. this.tableData.forEach(element => {
  729. if (element.type != 0) {
  730. this.searchData.type = 1
  731. } else {
  732. this.searchData.type = 0
  733. }
  734. });
  735. let obj = JSON.parse(JSON.stringify(this.searchData))
  736. obj.crt_time = parseInt(new Date(obj.crt_time).getTime() / 1000) || ''
  737. if (this.$route.query.order_in_no == '') {
  738. // 新增
  739. this.axios({
  740. method: 'post',
  741. url: '/api/warehouse_order_in_add',
  742. data: {
  743. ...obj,
  744. list: this.tableData,
  745. is_refer:this.is_refer
  746. }
  747. }).then((res) => {
  748. this.$Message.success(res.msg)
  749. this.goBack();
  750. }).catch((err) => { });
  751. } else {
  752. // 编辑
  753. this.axios({
  754. method: 'post',
  755. url: '/api/warehouse_order_in_edit',
  756. data: {
  757. order_in_no: this.$route.query.order_in_no,
  758. ...obj,
  759. list: this.tableData,
  760. is_refer:this.is_refer
  761. }
  762. }).then((res) => {
  763. this.$Message.success(res.msg)
  764. this.goBack();
  765. }).catch((err) => { });
  766. }
  767. },
  768. handleReference (type, refer_type) {
  769. let title = type == 5 ? '参照采购单' : type == 6 ? '参照到货单' : '参照质检单'
  770. this.$reference({
  771. type,
  772. title, refer_type,
  773. then: (result, data) => {
  774. this.tableData = [...this.tableData, ...result]
  775. this.is_refer = 1
  776. this.btn_disable = true
  777. if(type === 5){
  778. this.btn2_disable = true
  779. this.btn3_disable = true
  780. }
  781. else if(type === 6){
  782. this.btn1_disable = true
  783. this.btn3_disable = true
  784. }else{
  785. this.btn1_disable = true
  786. this.btn2_disable = true
  787. }
  788. }
  789. })
  790. },
  791. handleSet (type, row, index) {
  792. this.tableData.splice(index, 1)
  793. },
  794. handleSelect () {
  795. this.modalData.selectedData.forEach(element => {
  796. element.type_title = element.title
  797. element.type == 0
  798. });
  799. this.tableData = [...this.tableData, ...this.modalData.selectedData]
  800. this.is_refer = 0
  801. this.btn1_disable = true
  802. this.btn2_disable = true
  803. this.btn3_disable = true
  804. },
  805. handleTreeSlect (array, row) {
  806. row.id && this.axios({
  807. method: 'get',
  808. url: '/api/material_detail_list',
  809. params: {
  810. page_index: this.modal_page_index,
  811. page_size: this.modal_page_size,
  812. m_id: row.id
  813. }
  814. }).then((res) => {
  815. this.modal_total = res.data.total
  816. this.modalData.tableData = res.data.data
  817. }).catch((err) => { });
  818. },
  819. handleSelectionCancel (selection, row) {
  820. this.modalData.selectedData.forEach((element, index) => {
  821. if (element.material_detail_id == row.material_detail_id) {
  822. this.modalData.selectedData.splice(index, 1)
  823. }
  824. });
  825. },
  826. handleSelectionAll (selection) {
  827. this.modalData.selectedData = this.modalData.selectedData.concat(selection)
  828. },
  829. handleSelectionAllCancel () {
  830. this.modalData.tableData.forEach(element => {
  831. this.modalData.selectedData = this.modalData.selectedData.filter((x) => {
  832. return x.material_detail_id != element.material_detail_id
  833. })
  834. });
  835. },
  836. reselection () {
  837. this.modalData.selectedData.forEach(element => {
  838. this.modalData.tableData.forEach((ele, idx) => {
  839. if (element.material_detail_id == ele.material_detail_id) {
  840. this.$nextTick(() => {
  841. this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true
  842. this.$forceUpdate()
  843. })
  844. }
  845. });
  846. });
  847. },
  848. changeModalSize (e) {
  849. this.modal_page_size = e;
  850. this.initModal()
  851. },
  852. changeModalPage (e) {
  853. this.modal_page_index = e;
  854. this.initModal()
  855. },
  856. initModal () {
  857. this.axios({
  858. method: 'get',
  859. url: '/api/material_detail_list',
  860. params: {
  861. page_index: this.modal_page_index,
  862. page_size: this.modal_page_size,
  863. title: this.modalData.title
  864. }
  865. }).then((res) => {
  866. this.modal_total = res.data.total
  867. this.modalData.tableData = res.data.data
  868. this.reselection()
  869. }).catch((err) => { });
  870. },
  871. handleSelection (selection, row) {
  872. this.modalData.selectedData.push(row)
  873. },
  874. handleSelectedDele (row, index) {
  875. this.modalData.selectedData.splice(index, 1)
  876. },
  877. goBack () { this.$router.go(-1) },
  878. handleProjectSelect () {
  879. this.searchData.residential_name = this.currentChoose.residential_name
  880. this.searchData.order_no = this.currentChoose.order_no
  881. },
  882. handleSupplierSelect () {
  883. this.searchData.supply_title = this.currentChoose.title
  884. this.searchData.supply_id = this.currentChoose.id
  885. },
  886. changeProjectModalSize (e) {
  887. this.modal_project_page_size = e
  888. this.initProjectModal()
  889. },
  890. changeProjectModalPage (e) {
  891. this.modal_project_page_index = e
  892. this.initProjectModal()
  893. },
  894. initProjectModal () {
  895. this.axios({
  896. method: 'get',
  897. url: '/api/order_index',
  898. params: {
  899. page_index: this.modal_project_page_index,
  900. page_size: this.modal_project_page_size,
  901. title: this.modalProjectData.title
  902. }
  903. }).then((res) => {
  904. this.modal_project_total = res.data.total
  905. this.modalProjectData.tableData = res.data.data
  906. }).catch((err) => { });
  907. },
  908. changeSupplierModalSize (e) {
  909. this.modal_supplier_page_size = e
  910. this.initSupplierModal(this.modalSupplierData)
  911. },
  912. changeSupplierModalPage (e) {
  913. this.modal_supplier_page_index = e
  914. this.initSupplierModal(this.modalSupplierData)
  915. },
  916. initSupplierModal (searchData) {
  917. this.axios({
  918. method: 'get',
  919. url: '/api/supply_list',
  920. params: {
  921. page_index: this.modal_supplier_page_index,
  922. page_size: this.modal_supplier_page_size,
  923. title: searchData.title,
  924. code: searchData.code,
  925. }
  926. }).then((res) => {
  927. this.modal_supplier_total = res.data.total
  928. this.modalSupplierData.tableData = res.data.data
  929. }).catch((err) => { });
  930. },
  931. handleSupplierTreeSlect (arr, row) {
  932. this.modalSupplierData.code = row.code
  933. this.initSupplierModal(this.modalSupplierData)
  934. },
  935. },
  936. // 监听属性 类似于data概念
  937. computed: {},
  938. // 监控data中的数据变化
  939. watch: {},
  940. beforeCreate () { }, // 生命周期 - 创建之前
  941. beforeMount () { }, // 生命周期 - 挂载之前
  942. beforeUpdate () { }, // 生命周期 - 更新之前
  943. updated () { }, // 生命周期 - 更新之后
  944. beforeDestroy () { }, // 生命周期 - 销毁之前
  945. destroyed () { }, // 生命周期 - 销毁完成
  946. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  947. }
  948. </script>
  949. <style lang='scss' scoped>
  950. .content_topform {
  951. padding-top: 20px;
  952. /deep/.ivu-form {
  953. display: flex;
  954. justify-content: flex-start;
  955. align-items: flex-start;
  956. flex-wrap: wrap;
  957. }
  958. /deep/.ivu-form-item {
  959. display: inline-block;
  960. width: 300px;
  961. }
  962. }
  963. .content_table {
  964. .content_table_btn {
  965. display: flex;
  966. justify-content: space-between;
  967. align-items: center;
  968. padding-bottom: 20px;
  969. }
  970. .content_table_btn_right {
  971. display: flex;
  972. justify-content: flex-start;
  973. align-items: center;
  974. }
  975. }
  976. .modal_content {
  977. display: flex;
  978. justify-content: center;
  979. overflow: hidden;
  980. overflow-y: auto;
  981. .modal_content_left {
  982. }
  983. .modal_content_center {
  984. width: 80%;
  985. border-left: 1px solid #666;
  986. border-right: 1px solid #666;
  987. padding: 0 20px;
  988. .modal_content_center_top {
  989. display: flex;
  990. justify-content: flex-start;
  991. align-items: center;
  992. span {
  993. width: 100px;
  994. }
  995. div {
  996. display: flex;
  997. justify-content: space-around;
  998. align-items: center;
  999. span {
  1000. width: 100px;
  1001. }
  1002. }
  1003. .modal_content_center_body {
  1004. overflow: hidden;
  1005. overflow-y: auto;
  1006. height: 500px;
  1007. }
  1008. }
  1009. .modal_content_center_body {
  1010. padding-top: 20px;
  1011. }
  1012. .modal_content_center_footer {
  1013. display: flex;
  1014. justify-content: center;
  1015. padding-top: 20px;
  1016. }
  1017. }
  1018. .modal_content_right {
  1019. width: 30%;
  1020. padding: 0 20px;
  1021. }
  1022. }
  1023. /deep/ .ivu-table-wrapper {
  1024. overflow: visible;
  1025. } //穿透iview
  1026. </style>