edit.vue 29 KB

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