edit.vue 34 KB

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