edit.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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="$route.query.type == 2?tableColumns_detailed: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_detailed:[ { title: '物料分类', key: 'type_title', align: 'center', minWidth: 140 },
  404. { title: '物料名称', key: 'title', align: 'center', minWidth: 140 },
  405. {
  406. title: '物料规格', key: '', align: 'center', minWidth: 140,
  407. render: (h, params) => {
  408. const { row } = params
  409. let text = `${row.long ? row.long : 0}*${row.width ? row.width : 0}*${row.high ? row.high : 0}`
  410. return h('span', {}, text)
  411. }
  412. },
  413. { title: '计量单位', key: 'unit', align: 'center', minWidth: 100 },
  414. {
  415. title: '入库数量', key: 'num', align: 'center', minWidth: 120,slot:"numberSet"
  416. }],
  417. tableColumns: [
  418. { title: '物料分类', key: 'type_title', align: 'center', minWidth: 140 },
  419. { title: '物料名称', key: 'title', align: 'center', minWidth: 140 },
  420. {
  421. title: '物料规格', key: '', align: 'center', minWidth: 140,
  422. render: (h, params) => {
  423. const { row } = params
  424. let text = `${row.long ? row.long : 0}*${row.width ? row.width : 0}*${row.high ? row.high : 0}`
  425. return h('span', {}, text)
  426. }
  427. },
  428. { title: '计量单位', key: 'unit', align: 'center', minWidth: 100 },
  429. {
  430. title: '数量', key: 'num', align: 'center', minWidth: 120,slot:"numberSet"
  431. // render: (h, params) => {
  432. // const { row, index } = params
  433. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  434. // return this.$route.query.type == 2 ? h('span', {}, currentRow.num)
  435. // : h('Input', {
  436. // props: {
  437. // value: currentRow.num,
  438. // type: 'text'
  439. // },
  440. // on: {
  441. // 'on-change': (e) => {
  442. // currentRow.num = e.target.value
  443. // // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  444. // // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  445. // // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  446. // this.tableData.splice(index, 1, currentRow);
  447. // }
  448. // }
  449. // })
  450. // }
  451. },
  452. {
  453. title: '单价', key: 'total_price', align: 'center', minWidth: 120,
  454. render: (h, params) => {
  455. const { row, index } = params
  456. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  457. return this.$route.query.type == 2 ? h('span', {}, currentRow.total_price)
  458. :
  459. h('Input', {
  460. props: {
  461. value: currentRow.total_price,
  462. type: 'text'
  463. },
  464. on: {
  465. 'on-change': (e) => {
  466. currentRow.total_price = e.target.value
  467. this.tableData.splice(index, 1, currentRow);
  468. }
  469. }
  470. })
  471. }
  472. },
  473. {
  474. title: "金额", key: "total", align: "center", minWidth: 100,
  475. render: (h, params) => {
  476. const { row, index } = params;
  477. const currentRow = JSON.parse(
  478. JSON.stringify(this.tableData[index])
  479. );
  480. return h("span", {},currentRow.total_price&&currentRow.num?currentRow.total_price*currentRow.num:0)
  481. }
  482. },
  483. { title: '操作', key: 'code', align: 'center', minWidth: 100, slot: 'setSlot' },
  484. ],
  485. is_refer:'',
  486. tableData: [],
  487. showModal: false,
  488. showProjectModal: false,
  489. showSupplierModal: false,
  490. modalTableLoading: false,
  491. modalProjectTableLoading: false,
  492. modalSupplierTableLoading: false,
  493. modal_project_page_index: 1,
  494. modal_project_page_size: 10,
  495. modal_project_total: 0,
  496. modal_supplier_page_index: 1,
  497. modal_supplier_page_size: 10,
  498. modal_supplier_total: 0,
  499. currentChoose: {},
  500. modalProjectTableColumns: [
  501. {
  502. title: '选择', key: '', align: 'center', minWidth: 60,
  503. render: (h, params) => {
  504. let id = params.row.id;
  505. let flag = false;
  506. if (this.currentChoose.id == id) {
  507. flag = true
  508. } else {
  509. flag = false
  510. }
  511. let self = this
  512. return h('div', [
  513. h('Radio', {
  514. props: {
  515. value: flag
  516. },
  517. on: {
  518. 'on-change': () => {
  519. self.currentChoose = params.row;
  520. }
  521. }
  522. })
  523. ])
  524. }
  525. },
  526. { title: '项目名称', key: 'residential_name', align: 'center', minWidth: 100 },
  527. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 80, slot: 'basicTypeSet', },
  528. {
  529. title: '创建时间', key: 'crt_time', align: 'center', minWidth: 110,
  530. render: (h, params) => {
  531. const { row } = params
  532. return h('span', {}, this.func.replaceDate(row.crt_time))
  533. }
  534. },
  535. ],
  536. modalSupplierTableColumns: [
  537. {
  538. title: '选择', key: '', align: 'center', minWidth: 60,
  539. render: (h, params) => {
  540. let id = params.row.id;
  541. let flag = false;
  542. if (this.currentChoose.id == id) {
  543. flag = true
  544. } else {
  545. flag = false
  546. }
  547. let self = this
  548. return h('div', [
  549. h('Radio', {
  550. props: {
  551. value: flag
  552. },
  553. on: {
  554. 'on-change': () => {
  555. self.currentChoose = params.row;
  556. }
  557. }
  558. })
  559. ])
  560. }
  561. },
  562. { title: '供应商编码', key: 'code', align: 'center', minWidth: 100 },
  563. { title: '供应商名称', key: 'title', align: 'center', minWidth: 80, },
  564. { title: '负责人', key: 'contact', align: 'center', minWidth: 110, },
  565. { title: '联系方式', key: 'mobile', align: 'center', minWidth: 110, },
  566. ],
  567. modalData: {
  568. title: '',
  569. tableData: [{}],
  570. selectedData: [],
  571. treeData: [
  572. {
  573. title: '物料分类',
  574. expand: true,
  575. list: [],
  576. render: (h, { root, node, data }) => {
  577. return h('span', {
  578. style: {
  579. display: 'inline-block',
  580. width: '100%'
  581. }
  582. }, [
  583. h('span', [
  584. h('Icon', {
  585. props: {
  586. type: 'ios-folder-outline'
  587. },
  588. style: {
  589. marginRight: '8px'
  590. }
  591. }),
  592. h('span', data.title)
  593. ]),
  594. h('span', {
  595. style: {
  596. display: 'inline-block',
  597. // float: 'right',
  598. marginRight: '32px'
  599. }
  600. })
  601. ]);
  602. },
  603. }
  604. ],
  605. },
  606. selectedColumns: [
  607. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  608. { title: '操作', key: 'title', align: 'center', minWidth: 90, slot: 'selectedSetSlot' },
  609. ],
  610. modal_page_index: 1,
  611. modal_page_size: 10,
  612. modal_total: 0,
  613. modalTableColumns: [
  614. { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  615. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  616. { title: '物料规格', key: 'model', align: 'center', minWidth: 110 },
  617. { title: '计量单位', key: 'unit', align: 'center', minWidth: 110 },
  618. ],
  619. warehouseList: [],
  620. purchaseTypeList: [],
  621. warningList: [],
  622. warehouse:'',
  623. }
  624. },
  625. // 生命周期 - 创建完成(可以访问当前this实例)
  626. created () {
  627. this.$route.query.type == 2
  628. ? (this.isCheck = true)
  629. : (this.isCheck = false);
  630. // 获取采购类型
  631. this.axios({ method: 'get', url: '/api/basic_order_in_list', }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
  632. // 获取基础物料类型
  633. this.axios({ method: 'get', url: '/api/basics_material_index_level', }).then((res) => { this.modalData.treeData[0].list = res.data }).catch((err) => { });
  634. // 获取仓库列表
  635. this.axios({ method: 'get', url: '/api/warehouse', }).then((res) => { this.warehouseList = res.data }).catch((err) => { });
  636. // 获取供应商列表
  637. this.axios({ method: 'get', url: '/api/supply_list', }).then((res) => { this.suppliersList = res.data.data }).catch((err) => { });
  638. // 获取供应商分类
  639. this.axios({ method: 'get', url: '/api/basic_supply_list', }).then((res) => { this.modalSupplierData.treeData[0].sub = res.data }).catch((err) => { });
  640. // 获取项目列表
  641. this.axios({ method: 'get', url: '/api/order_index', }).then((res) => {
  642. this.modalProjectData.tableData = res.data.data
  643. this.modal_project_total = res.data.total
  644. }).catch((err) => { });
  645. // 获取紧急程度
  646. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  647. this.initModal()
  648. this.initProjectModal()
  649. this.initSupplierModal(this.modalSupplierData)
  650. },
  651. // 生命周期 - 挂载完成(可以访问DOM元素)
  652. mounted () {
  653. if (this.$route.query.order_in_no != '') {
  654. this.initData(this.$route.query.order_in_no)
  655. }
  656. },
  657. methods: {
  658. handleToolShow(index, row) {
  659. if (this.warehouse) {
  660. return
  661. } else {
  662. this.axios
  663. .get("/api/warehouse_stock_number", {
  664. params: {
  665. material_id: row.material_id,
  666. material_detail_id: row.material_detail_id,
  667. },
  668. })
  669. .then((res) => {
  670. this.warehouse= res.data
  671. });
  672. }
  673. // this.warehouse.num = this.warehouseTotal[index].num;
  674. // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
  675. },
  676. handleSummary ({ columns, data }) {
  677. const sums = {};
  678. columns.forEach((column, index) => {
  679. const key = column.key;
  680. if (index === 0) {
  681. sums[key] = {
  682. key,
  683. value: '合计'
  684. };
  685. return;
  686. }
  687. let val = data;
  688. for(let i in val){
  689. val[i].total = val[i].total_price*val[i].num;
  690. }
  691. const values = val.map(item => Number(item[key]));
  692. if (index === 6) {
  693. const v = values.reduce((prev, curr) => {
  694. const value = Number(curr);
  695. if (!isNaN(value)) {
  696. return prev + curr;
  697. } else {
  698. return prev;
  699. }
  700. }, 0);
  701. sums[key] = {
  702. key,
  703. value: v
  704. };
  705. }else if(index===4){
  706. const v = values.reduce((prev, curr) => {
  707. const value = Number(curr);
  708. if (!isNaN(value)) {
  709. return prev + curr;
  710. } else {
  711. return prev;
  712. }
  713. }, 0);
  714. sums[key] = {
  715. key,
  716. value: v
  717. };
  718. }
  719. else {
  720. sums[key] = {
  721. key,
  722. value: ''
  723. };
  724. }
  725. });
  726. return sums;
  727. },
  728. initData (order_in_no) {
  729. this.axios({
  730. method: 'get',
  731. url: '/api/warehouse_order_in_detail',
  732. params: { order_in_no }
  733. }).then((res) => {
  734. this.tableData = res.data.list
  735. const data = JSON.parse(JSON.stringify(res.data))
  736. delete data.list
  737. this.searchData = data
  738. }).catch((err) => { });
  739. },
  740. postData () {
  741. this.tableData.forEach(element => {
  742. if (element.type != 0) {
  743. this.searchData.type = 1
  744. } else {
  745. this.searchData.type = 0
  746. }
  747. });
  748. let obj = JSON.parse(JSON.stringify(this.searchData))
  749. obj.crt_time = parseInt(new Date(obj.crt_time).getTime() / 1000) || ''
  750. if (this.$route.query.order_in_no == '') {
  751. // 新增
  752. this.axios({
  753. method: 'post',
  754. url: '/api/warehouse_order_in_add',
  755. data: {
  756. ...obj,
  757. list: this.tableData,
  758. is_refer:this.is_refer
  759. }
  760. }).then((res) => {
  761. this.$Message.success(res.msg)
  762. this.goBack();
  763. }).catch((err) => { });
  764. } else {
  765. // 编辑
  766. this.axios({
  767. method: 'post',
  768. url: '/api/warehouse_order_in_edit',
  769. data: {
  770. order_in_no: this.$route.query.order_in_no,
  771. ...obj,
  772. list: this.tableData,
  773. is_refer:this.is_refer
  774. }
  775. }).then((res) => {
  776. this.$Message.success(res.msg)
  777. this.goBack();
  778. }).catch((err) => { });
  779. }
  780. },
  781. handleReference (type, refer_type) {
  782. let title = type == 5 ? '参照采购单' : type == 6 ? '参照到货单' : '参照质检单'
  783. this.$reference({
  784. type,
  785. title, refer_type,
  786. then: (result, data) => {
  787. this.tableData = [...this.tableData, ...result]
  788. this.is_refer = 1
  789. this.btn_disable = true
  790. if(type === 5){
  791. this.btn2_disable = true
  792. this.btn3_disable = true
  793. }
  794. else if(type === 6){
  795. this.btn1_disable = true
  796. this.btn3_disable = true
  797. }else{
  798. this.btn1_disable = true
  799. this.btn2_disable = true
  800. }
  801. }
  802. })
  803. },
  804. handleSet (type, row, index) {
  805. this.tableData.splice(index, 1)
  806. },
  807. handleSelect () {
  808. this.modalData.selectedData.forEach(element => {
  809. element.type_title = element.title
  810. element.type == 0
  811. });
  812. this.tableData = [...this.tableData, ...this.modalData.selectedData]
  813. this.is_refer = 0
  814. this.btn1_disable = true
  815. this.btn2_disable = true
  816. this.btn3_disable = true
  817. },
  818. handleTreeSlect (array, row) {
  819. row.id && this.axios({
  820. method: 'get',
  821. url: '/api/material_detail_list',
  822. params: {
  823. page_index: this.modal_page_index,
  824. page_size: this.modal_page_size,
  825. m_id: row.id
  826. }
  827. }).then((res) => {
  828. this.modal_total = res.data.total
  829. this.modalData.tableData = res.data.data
  830. }).catch((err) => { });
  831. },
  832. handleSelectionCancel (selection, row) {
  833. this.modalData.selectedData.forEach((element, index) => {
  834. if (element.material_detail_id == row.material_detail_id) {
  835. this.modalData.selectedData.splice(index, 1)
  836. }
  837. });
  838. },
  839. handleSelectionAll (selection) {
  840. this.modalData.selectedData = this.modalData.selectedData.concat(selection)
  841. },
  842. handleSelectionAllCancel () {
  843. this.modalData.tableData.forEach(element => {
  844. this.modalData.selectedData = this.modalData.selectedData.filter((x) => {
  845. return x.material_detail_id != element.material_detail_id
  846. })
  847. });
  848. },
  849. reselection () {
  850. this.modalData.selectedData.forEach(element => {
  851. this.modalData.tableData.forEach((ele, idx) => {
  852. if (element.material_detail_id == ele.material_detail_id) {
  853. this.$nextTick(() => {
  854. this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true
  855. this.$forceUpdate()
  856. })
  857. }
  858. });
  859. });
  860. },
  861. changeModalSize (e) {
  862. this.modal_page_size = e;
  863. this.initModal()
  864. },
  865. changeModalPage (e) {
  866. this.modal_page_index = e;
  867. this.initModal()
  868. },
  869. initModal () {
  870. this.axios({
  871. method: 'get',
  872. url: '/api/material_detail_list',
  873. params: {
  874. page_index: this.modal_page_index,
  875. page_size: this.modal_page_size,
  876. title: this.modalData.title
  877. }
  878. }).then((res) => {
  879. this.modal_total = res.data.total
  880. this.modalData.tableData = res.data.data
  881. this.reselection()
  882. }).catch((err) => { });
  883. },
  884. handleSelection (selection, row) {
  885. this.modalData.selectedData.push(row)
  886. },
  887. handleSelectedDele (row, index) {
  888. this.modalData.selectedData.splice(index, 1)
  889. },
  890. goBack () { this.$router.go(-1) },
  891. handleProjectSelect () {
  892. this.searchData.residential_name = this.currentChoose.residential_name
  893. this.searchData.order_no = this.currentChoose.order_no
  894. },
  895. handleSupplierSelect () {
  896. this.searchData.supply_title = this.currentChoose.title
  897. this.searchData.supply_id = this.currentChoose.id
  898. },
  899. changeProjectModalSize (e) {
  900. this.modal_project_page_size = e
  901. this.initProjectModal()
  902. },
  903. changeProjectModalPage (e) {
  904. this.modal_project_page_index = e
  905. this.initProjectModal()
  906. },
  907. initProjectModal () {
  908. this.axios({
  909. method: 'get',
  910. url: '/api/order_index',
  911. params: {
  912. page_index: this.modal_project_page_index,
  913. page_size: this.modal_project_page_size,
  914. title: this.modalProjectData.title
  915. }
  916. }).then((res) => {
  917. this.modal_project_total = res.data.total
  918. this.modalProjectData.tableData = res.data.data
  919. }).catch((err) => { });
  920. },
  921. changeSupplierModalSize (e) {
  922. this.modal_supplier_page_size = e
  923. this.initSupplierModal(this.modalSupplierData)
  924. },
  925. changeSupplierModalPage (e) {
  926. this.modal_supplier_page_index = e
  927. this.initSupplierModal(this.modalSupplierData)
  928. },
  929. initSupplierModal (searchData) {
  930. this.axios({
  931. method: 'get',
  932. url: '/api/supply_list',
  933. params: {
  934. page_index: this.modal_supplier_page_index,
  935. page_size: this.modal_supplier_page_size,
  936. title: searchData.title,
  937. code: searchData.code,
  938. }
  939. }).then((res) => {
  940. this.modal_supplier_total = res.data.total
  941. this.modalSupplierData.tableData = res.data.data
  942. }).catch((err) => { });
  943. },
  944. handleSupplierTreeSlect (arr, row) {
  945. this.modalSupplierData.code = row.code
  946. this.initSupplierModal(this.modalSupplierData)
  947. },
  948. },
  949. // 监听属性 类似于data概念
  950. computed: {},
  951. // 监控data中的数据变化
  952. watch: {},
  953. beforeCreate () { }, // 生命周期 - 创建之前
  954. beforeMount () { }, // 生命周期 - 挂载之前
  955. beforeUpdate () { }, // 生命周期 - 更新之前
  956. updated () { }, // 生命周期 - 更新之后
  957. beforeDestroy () { }, // 生命周期 - 销毁之前
  958. destroyed () { }, // 生命周期 - 销毁完成
  959. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  960. }
  961. </script>
  962. <style lang='scss' scoped>
  963. .content_topform {
  964. padding-top: 20px;
  965. /deep/.ivu-form {
  966. display: flex;
  967. justify-content: flex-start;
  968. align-items: flex-start;
  969. flex-wrap: wrap;
  970. }
  971. /deep/.ivu-form-item {
  972. display: inline-block;
  973. width: 300px;
  974. }
  975. }
  976. .content_table {
  977. .content_table_btn {
  978. display: flex;
  979. justify-content: space-between;
  980. align-items: center;
  981. padding-bottom: 20px;
  982. }
  983. .content_table_btn_right {
  984. display: flex;
  985. justify-content: flex-start;
  986. align-items: center;
  987. }
  988. }
  989. .modal_content {
  990. display: flex;
  991. justify-content: center;
  992. overflow: hidden;
  993. overflow-y: auto;
  994. .modal_content_left {
  995. }
  996. .modal_content_center {
  997. width: 80%;
  998. border-left: 1px solid #666;
  999. border-right: 1px solid #666;
  1000. padding: 0 20px;
  1001. .modal_content_center_top {
  1002. display: flex;
  1003. justify-content: flex-start;
  1004. align-items: center;
  1005. span {
  1006. width: 100px;
  1007. }
  1008. div {
  1009. display: flex;
  1010. justify-content: space-around;
  1011. align-items: center;
  1012. span {
  1013. width: 100px;
  1014. }
  1015. }
  1016. .modal_content_center_body {
  1017. overflow: hidden;
  1018. overflow-y: auto;
  1019. height: 500px;
  1020. }
  1021. }
  1022. .modal_content_center_body {
  1023. padding-top: 20px;
  1024. }
  1025. .modal_content_center_footer {
  1026. display: flex;
  1027. justify-content: center;
  1028. padding-top: 20px;
  1029. }
  1030. }
  1031. .modal_content_right {
  1032. width: 30%;
  1033. padding: 0 20px;
  1034. }
  1035. }
  1036. /deep/ .ivu-table-wrapper {
  1037. overflow: visible;
  1038. } //穿透iview
  1039. </style>