detailsPage.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button
  7. type="danger"
  8. style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList"
  11. >返回列表
  12. </el-button>
  13. </div>
  14. <div class="add-customer-btn" v-if="showBut">
  15. <el-button
  16. type="primary"
  17. size="small"
  18. v-if="detailData.status == 1"
  19. class="el-button--small-yh "
  20. @click.stop="openEdit"
  21. >编辑
  22. </el-button>
  23. <el-button
  24. type="info"
  25. @click.stop="editCustomer('save')"
  26. v-if="form.deliveryStatus == '录入'"
  27. size="small"
  28. >确认收货</el-button
  29. >
  30. <el-button
  31. type="info"
  32. @click.stop="editCustomer('repeal')"
  33. v-if="form.deliveryStatus == '已收货'"
  34. size="small"
  35. >撤销收货</el-button
  36. >
  37. <el-button
  38. type="success"
  39. :disabled="!form.id"
  40. size="small"
  41. @click="copyDoc"
  42. >
  43. 复制单据
  44. </el-button>
  45. <el-button
  46. type="primary"
  47. :disabled="disabled"
  48. @click="editCustomer('submit')"
  49. :loading="subLoading"
  50. v-if="detailData.status != 1"
  51. size="small"
  52. >保存数据
  53. </el-button>
  54. </div>
  55. </div>
  56. <div class="customer-main">
  57. <trade-card title="基础信息">
  58. <avue-form
  59. ref="form"
  60. class="trading-form"
  61. v-model="form"
  62. :option="option"
  63. >
  64. <template slot="corpId">
  65. <crop-select
  66. v-model="form.corpId"
  67. corpType="KH"
  68. :disabled="detailData.status == 1"
  69. ></crop-select>
  70. </template>
  71. <template slot="storageId">
  72. <warehouse-select
  73. v-model="form.storageId"
  74. :configuration="configuration2"
  75. :disabled="detailData.status == 1"
  76. ></warehouse-select>
  77. </template>
  78. </avue-form>
  79. </trade-card>
  80. <trade-card title="商品信息">
  81. <avue-crud
  82. ref="crud"
  83. :data="data"
  84. :option="tableOption"
  85. @row-del="rowDel"
  86. @saveColumn="saveColumn"
  87. @resetColumn="resetColumn"
  88. :summary-method="summaryMethod"
  89. :cell-style="cellStyle"
  90. >
  91. <template slot="menuLeft">
  92. <el-button
  93. type="primary"
  94. icon="el-icon-plus"
  95. size="small"
  96. @click.stop="newDetails"
  97. :disabled="detailData.status == 1"
  98. >录入明细</el-button
  99. >
  100. <el-button
  101. type="info"
  102. icon="el-icon-printer"
  103. size="small"
  104. @click.stop="openReport()"
  105. >报表打印</el-button
  106. >
  107. </template>
  108. <template slot="taxRate" slot-scope="{ row }">
  109. <el-input
  110. v-if="row.$cellEdit"
  111. size="mini"
  112. v-model="row.taxRate"
  113. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  114. @change="taxRateChange(row)"
  115. placeholder="请输入"
  116. />
  117. <span v-else>{{ row.taxRate }}</span>
  118. </template>
  119. <template slot="specificationAndModel" slot-scope="{ row }">
  120. <el-select
  121. v-if="row.$cellEdit"
  122. v-model="row.specificationAndModel"
  123. filterable
  124. allow-create
  125. default-first-option
  126. placeholder="请输入"
  127. @focus="itemTypeFocus(row)"
  128. >
  129. <el-option
  130. v-for="(item, index) in itemtypeList"
  131. :key="index"
  132. :label="item.value"
  133. :value="item.value"
  134. >
  135. </el-option>
  136. </el-select>
  137. <span v-else>{{ row.itemType }}</span>
  138. </template>
  139. <template slot="menu" slot-scope="{ row, index }">
  140. <el-button
  141. size="small"
  142. icon="el-icon-edit"
  143. type="text"
  144. @click="rowCell(row, index)"
  145. :disabled="disabled"
  146. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  147. >
  148. <el-button
  149. size="small"
  150. icon="el-icon-edit"
  151. type="text"
  152. @click="rowDel(row)"
  153. >删 除</el-button
  154. >
  155. </template>
  156. <template slot="price" slot-scope="{ row }">
  157. <el-input
  158. v-if="row.$cellEdit"
  159. v-model="row.price"
  160. size="small"
  161. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  162. @change="priceChange(row)"
  163. ></el-input>
  164. <span v-else>{{ row.price }}</span>
  165. </template>
  166. <template slot="actualQuantity" slot-scope="{ row }">
  167. <el-input
  168. v-if="row.$cellEdit"
  169. v-model="row.actualQuantity"
  170. size="small"
  171. oninput='this.value=this.value.replace(/[^(\d)]/g,"")'
  172. @change="quantityChange(row)"
  173. ></el-input>
  174. <span v-else>{{ row.actualQuantity | IntegerFormat }}</span>
  175. </template>
  176. </avue-crud>
  177. </trade-card>
  178. <fee-info
  179. ref="feeInfo"
  180. :orderFeesList="orderFeesList"
  181. :disabled="detailData.status == 1"
  182. :inCropId="true"
  183. feeUrl="/blade-deliver-goods/deliveryfees/update"
  184. />
  185. <containerTitle title="合同附件"></containerTitle>
  186. <c-upload
  187. typeUpload="CK"
  188. :data="orderFilesList"
  189. :disabled="detailData.status == 1"
  190. :enumerationValue="76"
  191. deleteUrl="/blade-deliver-goods/deliveryfiles/update"
  192. />
  193. </div>
  194. <el-dialog
  195. title="导入商品"
  196. append-to-body
  197. class="el-dialogDeep"
  198. :visible.sync="dialogVisible"
  199. width="80%"
  200. :close-on-click-modal="false"
  201. :destroy-on-close="true"
  202. :close-on-press-escape="false"
  203. @close="closeGoods"
  204. top="5vh"
  205. v-dialog-drag
  206. >
  207. <span>
  208. <el-row>
  209. <el-col :span="4">
  210. <div>
  211. <el-scrollbar>
  212. <basic-container>
  213. <avue-tree
  214. :option="treeOption"
  215. @node-click="nodeClick"
  216. :style="treeStyle"
  217. />
  218. </basic-container>
  219. </el-scrollbar>
  220. </div>
  221. </el-col>
  222. <el-col :span="20">
  223. <avue-crud
  224. :option="goodsOption"
  225. :table-loading="loading"
  226. :data="goodsList"
  227. ref="goodsCrud"
  228. :search.sync="search"
  229. @search-change="searchChange"
  230. @refresh-change="refreshChange"
  231. @selection-change="selectionChange"
  232. @row-click="rowClick"
  233. :page.sync="page"
  234. @on-load="onLoad"
  235. @saveColumn="saveGoodsColumn"
  236. @resetColumn="resetGoodsColumn"
  237. :cell-style="cellStyle"
  238. ></avue-crud>
  239. </el-col>
  240. </el-row>
  241. </span>
  242. <span slot="footer" class="dialog-footer">
  243. <el-button @click="dialogVisible = false">取 消</el-button>
  244. <el-button
  245. type="primary"
  246. @click="importGoods"
  247. :disabled="selectionList.length == 0"
  248. >导入</el-button
  249. >
  250. </span>
  251. </el-dialog>
  252. <report-dialog
  253. :switchDialog="switchDialog"
  254. :reportId="form.id"
  255. reportName="客户询价"
  256. @onClose="onClose()"
  257. ></report-dialog>
  258. </div>
  259. </template>
  260. <script>
  261. import tableOption from "./config/customerContact.json";
  262. import goodsOption from "./config/commodity.json";
  263. import feeInfo from "@/components/fee-info/main";
  264. import {
  265. detail,
  266. submit,
  267. delItem,
  268. getDeptLazyTree,
  269. getGoods,
  270. getSpecification,
  271. save,
  272. repeal
  273. } from "@/api/exportTrade/receipt";
  274. import uploadFile from "@/components/upload-file/main";
  275. import reportDialog from "@/components/report-dialog/main";
  276. import { contrastObj, contrastList } from "@/util/contrastData";
  277. import {
  278. isvalidatemobile,
  279. validatename,
  280. micrometerFormat,
  281. IntegerFormat
  282. } from "@/util/validate";
  283. import _ from "lodash";
  284. export default {
  285. name: "detailsPageEdit",
  286. data() {
  287. const validatePhone = (rule, value, callback) => {
  288. if (value != "") {
  289. if (isvalidatemobile(value)[0]) {
  290. this.$message.error("手机号码格式不正确");
  291. callback(new Error(isvalidatemobile(value)[1]));
  292. } else {
  293. callback();
  294. }
  295. } else {
  296. callback();
  297. }
  298. };
  299. const validateName = (rule, value, callback) => {
  300. if (value != "") {
  301. if (validatename(value)) {
  302. this.$message.error("联系人格式不正确");
  303. callback(new Error(validatename(value)));
  304. } else {
  305. callback();
  306. }
  307. } else {
  308. callback();
  309. }
  310. };
  311. return {
  312. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  313. configuration2: {
  314. multipleChoices: false,
  315. multiple: false,
  316. collapseTags: false,
  317. placeholder: "请点击右边按钮选择",
  318. dicData: []
  319. },
  320. switchDialog: false,
  321. form: {
  322. deliveryStatus: "录入"
  323. },
  324. disabled: false,
  325. dialogVisible: false,
  326. tableOption: tableOption,
  327. option: {
  328. menuBtn: false,
  329. labelWidth: 100,
  330. disabled: false,
  331. column: [
  332. {
  333. label: "客户名称",
  334. prop: "corpId",
  335. rules: [
  336. {
  337. required: true,
  338. message: "",
  339. trigger: "blur"
  340. }
  341. ],
  342. span: 16,
  343. slot: true
  344. },
  345. {
  346. label: "系统号",
  347. prop: "sysNo",
  348. span: 8
  349. },
  350. {
  351. label: "采购订单号",
  352. prop: "srcOrderNo",
  353. span: 8
  354. },
  355. {
  356. label: "订单状态",
  357. prop: "deliveryStatus",
  358. span: 8,
  359. type: "select",
  360. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  361. props: {
  362. label: "dictValue",
  363. value: "dictValue"
  364. },
  365. disabled: true
  366. },
  367. {
  368. label: "仓库名称",
  369. prop: "storageId",
  370. span: 8
  371. },
  372. {
  373. label: "仓库类型",
  374. prop: "warehouseType",
  375. span: 8
  376. },
  377. {
  378. label: "收货日期",
  379. prop: "businessDate",
  380. span: 8,
  381. type: "date",
  382. format: "yyyy-MM-dd",
  383. valueFormat: "yyyy-MM-dd 00:00:00",
  384. rules: [
  385. {
  386. required: true,
  387. message: "",
  388. trigger: "blur"
  389. }
  390. ],
  391. row: true
  392. },
  393. {
  394. label: "入库金额",
  395. prop: "deliveryAmount",
  396. span: 8
  397. },
  398. {
  399. label: "入库数量",
  400. prop: "totalQuantity",
  401. span: 8
  402. },
  403. {
  404. label: "费用合计",
  405. prop: "totalCost",
  406. span: 8
  407. },
  408. {
  409. label: "发货人",
  410. prop: "arrivalContact",
  411. span: 8
  412. },
  413. {
  414. label: "发货电话",
  415. prop: "arrivalTel",
  416. span: 8
  417. },
  418. {
  419. label: "发货地址",
  420. prop: "arrivalAddress",
  421. span: 8
  422. },
  423. {
  424. label: "制单时间",
  425. prop: "createTime",
  426. span: 8,
  427. type: "date",
  428. format: "yyyy-MM-dd",
  429. valueFormat: "yyyy-MM-dd 00:00:00",
  430. disabled: true
  431. },
  432. {
  433. label: "备注",
  434. prop: "deliveryRemarks",
  435. type: "textarea",
  436. minRows: 2,
  437. span: 24
  438. }
  439. ]
  440. },
  441. treeOption: {
  442. nodeKey: "id",
  443. lazy: true,
  444. treeLoad: function(node, resolve) {
  445. const parentId = node.level === 0 ? 0 : node.data.id;
  446. getDeptLazyTree(parentId).then(res => {
  447. resolve(
  448. res.data.data.map(item => {
  449. return {
  450. ...item,
  451. leaf: !item.hasChildren
  452. };
  453. })
  454. );
  455. });
  456. },
  457. addBtn: false,
  458. menu: false,
  459. size: "small",
  460. props: {
  461. label: "title",
  462. value: "value",
  463. children: "children"
  464. }
  465. },
  466. page: {
  467. pageSize: 10,
  468. currentPage: 1,
  469. total: 0
  470. },
  471. loading: false,
  472. goodsOption: {},
  473. data: [],
  474. goodsList: [],
  475. selectionList: [],
  476. treeDeptId: null,
  477. orderFeesList: [],
  478. orderFilesList: [],
  479. itemtypeList: [],
  480. reData: null,
  481. oldform: {
  482. deliveryStatus: "录入"
  483. },
  484. olddata: [],
  485. oldorderFeesList: [],
  486. oldorderFilesList: [],
  487. subLoading: false,
  488. pageLoading: false,
  489. showBut: true,
  490. search: {}
  491. };
  492. },
  493. props: {
  494. detailData: {
  495. type: Object
  496. }
  497. },
  498. components: {
  499. reportDialog,
  500. feeInfo,
  501. uploadFile
  502. },
  503. async created() {
  504. if (this.detailData.id) {
  505. this.getDetail(this.detailData.id);
  506. }
  507. this.tableOption = await this.getColumnData(
  508. this.getColumnName(7),
  509. tableOption
  510. );
  511. this.goodsOption = await this.getColumnData(
  512. this.getColumnName(29),
  513. goodsOption
  514. );
  515. if (this.$route.query.pageType == "Generate") {
  516. this.getGenerate(JSON.parse(this.$route.query.data));
  517. }
  518. if (this.detailData.status == 1) {
  519. this.option.disabled = true;
  520. }
  521. this.getWorkDicts("product_properties").then(res => {
  522. this.findObject(this.tableOption.column, "itemProp").dicData =
  523. res.data.data;
  524. });
  525. this.getWorkDicts("unit").then(res => {
  526. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  527. });
  528. },
  529. filters: {
  530. IntegerFormat(num) {
  531. return IntegerFormat(num);
  532. }
  533. },
  534. methods: {
  535. cellStyle() {
  536. return "padding:0;height:40px;";
  537. },
  538. copyDoc() {
  539. this.$emit("copyOrder", this.form.id);
  540. },
  541. rePick(row, index) {
  542. this.reData = {
  543. ...row,
  544. index: index
  545. };
  546. this.newDetails();
  547. },
  548. getGenerate(data) {
  549. this.form = data;
  550. this.data = data.orderItemsList;
  551. this.orderFeesList = data.deliveryFeesList ? data.deliveryFeesList : [];
  552. },
  553. itemTypeFocus(row) {
  554. this.itemtypeList = [];
  555. getSpecification({ goodId: row.itemId }).then(res => {
  556. const data = res.data.data;
  557. this.itemtypeList = data.map(item => ({ value: item }));
  558. });
  559. },
  560. //编辑
  561. rowCell(row, index) {
  562. if (row.$cellEdit == true) {
  563. this.$set(row, "$cellEdit", false);
  564. } else {
  565. this.$set(row, "$cellEdit", true);
  566. }
  567. },
  568. priceChange(row) {
  569. console.log(row);
  570. if (!row.price) {
  571. row.price = 0;
  572. } else {
  573. row.contractAmount = _.multiply(row.price, row.actualQuantity).toFixed(
  574. 2
  575. );
  576. }
  577. },
  578. quantityChange(row) {
  579. if (!row.actualQuantity) {
  580. row.actualQuantity = 0;
  581. } else {
  582. row.contractAmount = _.multiply(row.price, row.actualQuantity).toFixed(
  583. 2
  584. );
  585. }
  586. },
  587. taxRateChange(row) {
  588. if (Number(row.taxRate) >= 100) {
  589. row.taxRate = 0;
  590. this.$message.error("税率不能超过100%");
  591. }
  592. },
  593. rowSave(row) {
  594. console.log(row);
  595. this.$set(row, "$cellEdit", false);
  596. },
  597. rowDel(row) {
  598. this.$confirm("确定删除数据?", {
  599. confirmButtonText: "确定",
  600. cancelButtonText: "取消",
  601. type: "warning"
  602. }).then(() => {
  603. if (row.id) {
  604. delItem(row.id).then(res => {
  605. this.$message({
  606. type: "success",
  607. message: "删除成功!"
  608. });
  609. this.data.splice(row.$index, 1);
  610. });
  611. } else {
  612. this.$message({
  613. type: "success",
  614. message: "删除成功!"
  615. });
  616. this.data.splice(row.$index, 1);
  617. }
  618. });
  619. },
  620. importGoods() {
  621. if (this.reData) {
  622. console.log(this.reData);
  623. if (this.selectionList.length != 1) {
  624. return this.$message.error("重新选择的时候只能选择一条数据");
  625. } else {
  626. this.selectionList.forEach(e => {
  627. this.data.forEach((item, index) => {
  628. if (index == this.reData.index) {
  629. item.itemId = e.id;
  630. item.code = e.code;
  631. item.cname = e.cname;
  632. item.priceCategory = e.goodsTypeName;
  633. item.itemUrl = e.url;
  634. item.itemProp = this.reData.itemProp;
  635. item.itemDescription = e.cnameDescription;
  636. item.itemType = this.reData.itemType;
  637. item.tradeTerms = this.reData.tradeTerms;
  638. item.price = this.reData.price;
  639. item.orderQuantity = this.reData.orderQuantity;
  640. item.insurance = this.reData.insurance;
  641. item.freight = this.reData.freight;
  642. item.discount = this.reData.discount;
  643. item.amount = this.reData.amount;
  644. item.taxRate = this.reData.taxRate;
  645. item.unit = e.unit;
  646. item.remarks = this.reData.remarks;
  647. item.$cellEdit = true;
  648. }
  649. });
  650. });
  651. }
  652. } else {
  653. this.selectionList.forEach(e => {
  654. this.data.push({
  655. itemId: e.id,
  656. code: e.code,
  657. cname: e.cname,
  658. priceCategory: e.goodsTypeName,
  659. itemUrl: e.url,
  660. itemProp: null,
  661. itemDescription: e.cnameDescription,
  662. itemType: null,
  663. tradeTerms: null,
  664. price: 0,
  665. orderQuantity: 0,
  666. insurance: 0,
  667. freight: 0,
  668. discount: null,
  669. amount: 0,
  670. taxRate: 0,
  671. unit: e.unit,
  672. remarks: null,
  673. $cellEdit: true
  674. });
  675. });
  676. }
  677. },
  678. closeGoods() {
  679. this.selectionList = [];
  680. this.treeDeptId = "";
  681. this.reData = null;
  682. },
  683. selectionChange(list) {
  684. this.selectionList = list;
  685. },
  686. rowClick(row) {
  687. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  688. },
  689. nodeClick(data) {
  690. this.treeDeptId = data.id;
  691. this.page.currentPage = 1;
  692. this.onLoad(this.page);
  693. },
  694. searchChange(params, done) {
  695. this.search = this.deepClone(params);
  696. this.onLoad(this.page, params);
  697. done();
  698. },
  699. //费用查询
  700. onLoad(page, params = {}) {
  701. let obj = this.deepClone(Object.assign(params, this.search));
  702. this.loading = true;
  703. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj).then(
  704. res => {
  705. const data = res.data.data;
  706. this.page.total = data.total;
  707. this.goodsList = data.records;
  708. this.loading = false;
  709. if (this.page.total) {
  710. this.goodsOption.height = window.innerHeight - 350;
  711. }
  712. }
  713. );
  714. },
  715. //商品明细导入
  716. newDetails() {
  717. this.dialogVisible = !this.dialogVisible;
  718. },
  719. getDetail(id) {
  720. this.showBut = false;
  721. this.pageLoading = true;
  722. detail(id)
  723. .then(res => {
  724. if (this.detailData.status == "copy") {
  725. delete res.data.data.id;
  726. delete res.data.data.sysNo;
  727. delete res.data.data.orderNo;
  728. delete res.data.data.orgOrderNo;
  729. delete res.data.data.srcOrderNo;
  730. delete res.data.data.createTime;
  731. delete res.data.data.createUser;
  732. delete res.data.data.createUserName;
  733. delete res.data.data.updateTime;
  734. delete res.data.data.updateUser;
  735. delete res.data.data.updateUserName;
  736. delete res.data.data.morderNo;
  737. delete res.data.data.status;
  738. delete res.data.data.ifEnquiry;
  739. delete res.data.data.ifShipping;
  740. res.data.data.orderStatus = "录入";
  741. res.data.data.deliveryItemsList.forEach(e => {
  742. delete e.id;
  743. delete e.pid;
  744. delete e.createTime;
  745. delete e.createUser;
  746. delete e.updateTime;
  747. delete e.updateUser;
  748. delete e.orgOrderNo;
  749. delete e.srcId;
  750. delete e.status;
  751. delete e.isDeleted;
  752. });
  753. res.data.data.deliveryFeesList.forEach(e => {
  754. delete e.id;
  755. delete e.pid;
  756. delete e.createTime;
  757. delete e.createUser;
  758. delete e.updateTime;
  759. delete e.updateUser;
  760. delete e.status;
  761. delete e.isDeleted;
  762. });
  763. res.data.data.deliveryFilesList.forEach(e => {
  764. delete e.id;
  765. delete e.pid;
  766. delete e.createTime;
  767. delete e.createUser;
  768. delete e.updateTime;
  769. delete e.updateUser;
  770. delete e.status;
  771. delete e.isDeleted;
  772. });
  773. }
  774. this.form = res.data.data;
  775. this.data = res.data.data.deliveryItemsList;
  776. this.orderFeesList = res.data.data.deliveryFeesList;
  777. this.orderFilesList = res.data.data.deliveryFilesList;
  778. this.oldform = res.data.data;
  779. this.olddata = this.deepClone(res.data.data.deliveryItemsList);
  780. this.oldorderFeesList = this.deepClone(
  781. res.data.data.deliveryFeesList
  782. );
  783. this.oldorderFilesList = this.deepClone(
  784. res.data.data.deliveryFilesList
  785. );
  786. })
  787. .finally(() => {
  788. this.showBut = true;
  789. this.pageLoading = false;
  790. });
  791. },
  792. //修改提交触发
  793. editCustomer(status, status2) {
  794. this.$refs["form"].validate((valid, done) => {
  795. done();
  796. if (valid) {
  797. let orderFeesList = this.$refs.feeInfo.submitData();
  798. for (let i = 0; i < orderFeesList.length; i++) {
  799. if (orderFeesList[i].corpId == null) {
  800. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  801. }
  802. if (orderFeesList[i].price == 0) {
  803. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  804. }
  805. if (orderFeesList[i].actualQuantity == 0) {
  806. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  807. }
  808. }
  809. this.data.forEach((e, index) => {
  810. e.sort = Number(index) + 1
  811. })
  812. if (status == "submit") {
  813. this.subLoading = true;
  814. submit({
  815. ...this.form,
  816. deliveryItemsList: this.data,
  817. deliveryFeesList: orderFeesList,
  818. deliveryFilesList: this.orderFilesList
  819. })
  820. .then(res => {
  821. this.form = res.data.data;
  822. this.data = res.data.data.deliveryItemsList;
  823. this.orderFeesList = res.data.data.deliveryFeesList;
  824. this.orderFilesList = res.data.data.deliveryFilesList;
  825. this.oldform = res.data.data;
  826. this.olddata = this.deepClone(res.data.data.deliveryItemsList);
  827. this.oldorderFeesList = this.deepClone(
  828. res.data.data.deliveryFeesList
  829. );
  830. this.oldorderFilesList = this.deepClone(
  831. res.data.data.deliveryFilesList
  832. );
  833. this.$message.success("保存成功");
  834. if (status2 == "goBack") {
  835. if (this.form.id) {
  836. this.unLock({
  837. moduleName: "sh",
  838. tableName: "business_order",
  839. billId: this.form.id,
  840. billNo: this.form.orgOrderNo
  841. });
  842. }
  843. this.$emit("goBack");
  844. this.leaveDetailsKey(this.$route.name);
  845. }
  846. })
  847. .finally(() => {
  848. this.subLoading = false;
  849. });
  850. }
  851. if (status == "save") {
  852. this.$confirm("此操作将确认收货, 是否继续?", "提示", {
  853. confirmButtonText: "确定",
  854. cancelButtonText: "取消",
  855. type: "warning"
  856. }).then(() => {
  857. save({
  858. ...this.form,
  859. deliveryItemsList: this.data,
  860. deliveryFeesList: orderFeesList,
  861. deliveryFilesList: this.orderFilesList
  862. }).then(res => {
  863. this.form = res.data.data;
  864. this.data = res.data.data.deliveryItemsList;
  865. this.orderFeesList = res.data.data.deliveryFeesList;
  866. this.orderFilesList = res.data.data.deliveryFilesList;
  867. this.$message.success("提交成功");
  868. this.oldform = res.data.data;
  869. this.olddata = this.deepClone(res.data.data.deliveryItemsList);
  870. this.oldorderFeesList = this.deepClone(
  871. res.data.data.deliveryFeesList
  872. );
  873. this.oldorderFilesList = this.deepClone(
  874. res.data.data.deliveryFilesList
  875. );
  876. });
  877. });
  878. }
  879. if (status == "repeal") {
  880. this.$confirm("此操作将撤销收货, 是否继续?", "提示", {
  881. confirmButtonText: "确定",
  882. cancelButtonText: "取消",
  883. type: "warning"
  884. }).then(() => {
  885. repeal({
  886. ...this.form,
  887. deliveryItemsList: this.data,
  888. deliveryFeesList: orderFeesList,
  889. deliveryFilesList: this.orderFilesList
  890. }).then(res => {
  891. this.form = res.data.data;
  892. this.data = res.data.data.deliveryItemsList;
  893. this.orderFeesList = res.data.data.deliveryFeesList;
  894. this.orderFilesList = res.data.data.deliveryFilesList;
  895. this.$message.success("撤销成功");
  896. this.oldform = res.data.data;
  897. this.olddata = this.deepClone(res.data.data.deliveryItemsList);
  898. this.oldorderFeesList = this.deepClone(
  899. res.data.data.deliveryFeesList
  900. );
  901. this.oldorderFilesList = this.deepClone(
  902. res.data.data.deliveryFilesList
  903. );
  904. });
  905. });
  906. }
  907. } else {
  908. return false;
  909. }
  910. });
  911. },
  912. //返回列表
  913. backToList() {
  914. let orderFeesList = this.$refs.feeInfo.submitData();
  915. if (
  916. contrastObj(this.form, this.oldform) ||
  917. contrastList(this.data, this.olddata) ||
  918. contrastList(orderFeesList, this.oldorderFeesList) ||
  919. contrastList(this.orderFilesList, this.oldorderFilesList)
  920. ) {
  921. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  922. confirmButtonText: "确定",
  923. cancelButtonText: "取消",
  924. type: "warning"
  925. })
  926. .then(() => {
  927. this.editCustomer("submit", "goBack");
  928. })
  929. .catch(() => {
  930. if (this.form.id) {
  931. this.unLock({
  932. moduleName: "sh",
  933. tableName: "business_order",
  934. billId: this.form.id,
  935. billNo: this.form.orgOrderNo
  936. });
  937. }
  938. this.$emit("goBack");
  939. this.leaveDetailsKey(this.$route.name);
  940. });
  941. } else {
  942. if (this.form.id) {
  943. this.unLock({
  944. moduleName: "sh",
  945. tableName: "business_order",
  946. billId: this.form.id,
  947. billNo: this.form.orgOrderNo
  948. });
  949. }
  950. this.$emit("goBack");
  951. this.leaveDetailsKey(this.$route.name);
  952. }
  953. },
  954. openReport() {
  955. this.switchDialog = !this.switchDialog;
  956. },
  957. onClose(val) {
  958. this.switchDialog = val;
  959. },
  960. summaryMethod({ columns, data }) {
  961. const sums = [];
  962. if (columns.length > 0) {
  963. columns.forEach((item, index) => {
  964. sums[0] = "合计";
  965. if (
  966. item.property == "actualQuantity" ||
  967. item.property == "contractAmount"
  968. ) {
  969. let qtySum = 0;
  970. let amountSum = 0;
  971. data.forEach(e => {
  972. qtySum = _.add(qtySum, Number(e.actualQuantity));
  973. amountSum = _.add(amountSum, Number(e.contractAmount));
  974. });
  975. //数量总计
  976. if (item.property == "actualQuantity") {
  977. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  978. }
  979. //金额总计
  980. if (item.property == "contractAmount") {
  981. sums[index] = micrometerFormat(amountSum);
  982. }
  983. }
  984. });
  985. }
  986. return sums;
  987. },
  988. openEdit() {
  989. const data = {
  990. moduleName: "sh",
  991. tableName: "business_order",
  992. billId: this.form.id,
  993. no: localStorage.getItem("browserID"),
  994. billNo: this.form.orgOrderNo
  995. };
  996. this.inDetailsKey(this.$route.name, {
  997. moduleName: "sh",
  998. tableName: "business_order",
  999. billId: this.form.id,
  1000. billNo: this.form.orgOrderNo
  1001. });
  1002. this.checkLock(data).then(res => {
  1003. if (res.data.code == 200) {
  1004. this.onLock(data).then(res => {
  1005. if (res.data.code == 200) {
  1006. this.detailData.status = 2;
  1007. this.option = this.$options.data().option;
  1008. }
  1009. });
  1010. }
  1011. });
  1012. },
  1013. async saveColumn() {
  1014. const inSave = await this.saveColumnData(
  1015. this.getColumnName(7),
  1016. this.tableOption
  1017. );
  1018. if (inSave) {
  1019. this.$nextTick(() => {
  1020. this.$refs.crud.doLayout()
  1021. })
  1022. this.$message.success("保存成功");
  1023. //关闭窗口
  1024. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1025. }
  1026. },
  1027. async resetColumn() {
  1028. this.tableOption = tableOption;
  1029. const inSave = await this.delColumnData(
  1030. this.getColumnName(7),
  1031. tableOption
  1032. );
  1033. if (inSave) {
  1034. this.$nextTick(() => {
  1035. this.$refs.crud.doLayout()
  1036. })
  1037. this.$message.success("重置成功");
  1038. //关闭窗口
  1039. setTimeout(() => {
  1040. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  1041. }, 1000);
  1042. }
  1043. },
  1044. async saveGoodsColumn() {
  1045. const inSave = await this.saveColumnData(
  1046. this.getColumnName(29),
  1047. this.goodsOption
  1048. );
  1049. if (inSave) {
  1050. this.$nextTick(() => {
  1051. this.$refs.goodsCrud.doLayout()
  1052. })
  1053. this.$message.success("保存成功");
  1054. //关闭窗口
  1055. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1056. }
  1057. },
  1058. async resetGoodsColumn() {
  1059. this.goodsOption = goodsOption;
  1060. const inSave = await this.delColumnData(
  1061. this.getColumnName(29),
  1062. goodsOption
  1063. );
  1064. if (inSave) {
  1065. this.$nextTick(() => {
  1066. this.$refs.goodsCrud.doLayout()
  1067. })
  1068. this.$message.success("重置成功");
  1069. //关闭窗口
  1070. setTimeout(() => {
  1071. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1072. }, 1000);
  1073. }
  1074. }
  1075. }
  1076. };
  1077. </script>
  1078. <style lang="scss" scoped>
  1079. .trading-form ::v-deep .el-form-item {
  1080. margin-bottom: 8px !important;
  1081. }
  1082. ::v-deep .el-form-item__error {
  1083. display: none !important;
  1084. }
  1085. ::v-deep .select-component {
  1086. display: flex !important;
  1087. }
  1088. </style>