edit.vue 36 KB

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