edit.vue 29 KB

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