detailsPage.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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. :disabled="detailData.status == 1"
  18. v-if="detailData.status != 1"
  19. @click="editCustomer('submit')"
  20. size="small"
  21. >提交
  22. </el-button>
  23. <el-button
  24. type="primary"
  25. :disabled="detailData.status == 1"
  26. @click="editCustomer('save')"
  27. :loading="subLoading"
  28. v-if="detailData.status != 1"
  29. size="small"
  30. >{{ form.id ? "确认修改" : "确认新增" }}
  31. </el-button>
  32. </div>
  33. </div>
  34. <div class="customer-main">
  35. <containerTitle title="基础信息"></containerTitle>
  36. <basic-container>
  37. <avue-form
  38. ref="form"
  39. class="trading-form"
  40. v-model="form"
  41. :option="option"
  42. >
  43. <template slot="corpId">
  44. <crop-select
  45. v-model="form.corpId"
  46. corpType="KH"
  47. :disabled="detailData.status == 1"
  48. ></crop-select>
  49. </template>
  50. </avue-form>
  51. </basic-container>
  52. <containerTitle title="商品信息"></containerTitle>
  53. <basic-container>
  54. <avue-crud
  55. ref="crud"
  56. :data="data"
  57. :option="tableOption"
  58. @row-del="rowDel"
  59. @saveColumn="saveColumn"
  60. :summary-method="summaryMethod"
  61. :cell-style="cellStyle"
  62. >
  63. <template slot="cname" slot-scope="{ row, index }">
  64. <span v-if="row.$cellEdit" style="display:flex">
  65. <el-select
  66. v-model="row.cname"
  67. placeholder="请选择"
  68. size="small"
  69. style="width:60%"
  70. @change="cnameChange(row, index)"
  71. >
  72. <el-option
  73. v-for="item in goodsoptions"
  74. :key="item.id"
  75. :label="item.cname"
  76. :value="item.cname"
  77. >
  78. </el-option>
  79. </el-select>
  80. <el-button
  81. icon="el-icon-search"
  82. size="mini"
  83. @click="rePick(row, index)"
  84. ></el-button>
  85. </span>
  86. <span v-else> {{ row.cname }}</span>
  87. </template>
  88. <template slot="price" slot-scope="{ row }">
  89. <el-input
  90. v-if="row.$cellEdit"
  91. v-model="row.price"
  92. size="small"
  93. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  94. @change="priceChange(row)"
  95. ></el-input>
  96. <span v-else>{{ row.price }}</span>
  97. </template>
  98. <template slot="taxRate" slot-scope="{ row }">
  99. <el-input
  100. v-if="row.$cellEdit"
  101. v-model="row.taxRate"
  102. size="small"
  103. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  104. @change="priceChange(row)"
  105. ></el-input>
  106. <span v-else>{{ row.taxRate ? row.taxRate : 0 }}%</span>
  107. </template>
  108. <template slot="coefficient" slot-scope="{ row }">
  109. <el-input
  110. v-if="row.$cellEdit"
  111. v-model="row.coefficient"
  112. size="small"
  113. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  114. @change="priceChange(row)"
  115. ></el-input>
  116. <span v-else>{{ row.coefficient ? row.coefficient : 0 }}%</span>
  117. </template>
  118. <template slot="orderQuantity" slot-scope="{ row }">
  119. <el-input
  120. v-if="row.$cellEdit"
  121. v-model="row.orderQuantity"
  122. size="small"
  123. oninput='this.value=this.value.replace(/[^(\d)]/g,"")'
  124. @change="quantityChange(row)"
  125. ></el-input>
  126. <span v-else>{{ row.orderQuantity }}</span>
  127. </template>
  128. <template slot="itemType" slot-scope="{ row }">
  129. <el-select
  130. v-if="row.$cellEdit"
  131. v-model="row.itemType"
  132. filterable
  133. allow-create
  134. default-first-option
  135. placeholder="请输入"
  136. size="small"
  137. @focus="itemTypeFocus(row)"
  138. >
  139. <el-option
  140. v-for="(item, index) in itemtypeList"
  141. :key="index"
  142. :label="item.value"
  143. :value="item.value"
  144. >
  145. </el-option>
  146. </el-select>
  147. <span v-else>{{ row.itemType }}</span>
  148. </template>
  149. <template slot="priorityReferrer" slot-scope="{ row }">
  150. <el-checkbox
  151. :disabled="!row.$cellEdit"
  152. v-model="row.priorityReferrer"
  153. :true-label="1"
  154. :false-label="0"
  155. />
  156. </template>
  157. <template slot="corpId" slot-scope="{ row, index }">
  158. <crop-select
  159. v-show="row.$cellEdit"
  160. v-model="row.corpId"
  161. :cropIndex="index"
  162. @getCorpData="rowCorpData"
  163. corpType="GYS"
  164. ></crop-select>
  165. <span v-show="!row.$cellEdit">{{ row.corpName }}</span>
  166. </template>
  167. <template slot="purchaseAmount" slot-scope="{ row }">
  168. <span>{{ row.purchaseAmount | micrometerFormat }}</span>
  169. </template>
  170. <template slot="menuLeft">
  171. <el-button
  172. type="primary"
  173. icon="el-icon-plus"
  174. size="small"
  175. @click.stop="newDetails"
  176. :disabled="detailData.status == 1"
  177. >新增明细</el-button
  178. >
  179. <el-button
  180. type="info"
  181. icon="el-icon-printer"
  182. size="small"
  183. @click.stop="openReport()"
  184. :disabled="detailData.status == 1"
  185. >报 表</el-button
  186. >
  187. </template>
  188. <template slot="menu" slot-scope="{ row, index }">
  189. <el-button
  190. size="small"
  191. icon="el-icon-edit"
  192. type="text"
  193. @click="rowCell(row, index)"
  194. :disabled="detailData.status == 1"
  195. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  196. >
  197. <el-button
  198. size="small"
  199. icon="el-icon-edit"
  200. type="text"
  201. @click="rowDel(row, index)"
  202. :disabled="detailData.status == 1"
  203. >删 除</el-button
  204. >
  205. </template>
  206. </avue-crud>
  207. </basic-container>
  208. </div>
  209. <el-dialog
  210. title="导入商品"
  211. append-to-body
  212. class="el-dialogDeep"
  213. :visible.sync="dialogVisible"
  214. width="60%"
  215. :close-on-click-modal="false"
  216. :destroy-on-close="true"
  217. :close-on-press-escape="false"
  218. @close="closeGoods"
  219. top="5vh"
  220. v-dialog-drag
  221. >
  222. <span>
  223. <el-row>
  224. <el-col :span="5">
  225. <div>
  226. <el-scrollbar>
  227. <basic-container style="margin-top:45px">
  228. <avue-tree :option="treeOption" @node-click="nodeClick" />
  229. </basic-container>
  230. </el-scrollbar>
  231. </div>
  232. </el-col>
  233. <el-col :span="19">
  234. <avue-crud
  235. :option="goodsOption"
  236. :table-loading="loading"
  237. :data="goodsList"
  238. ref="goodsCrud"
  239. @refresh-change="refreshChange"
  240. @selection-change="selectionChange"
  241. @row-click="rowClick"
  242. :page.sync="page"
  243. @on-load="onLoad"
  244. @saveColumn="saveGoodsColumn"
  245. ></avue-crud>
  246. </el-col>
  247. </el-row>
  248. </span>
  249. <span slot="footer" class="dialog-footer">
  250. <el-button @click="dialogVisible = false">取 消</el-button>
  251. <el-button
  252. type="primary"
  253. @click="importGoods"
  254. :disabled="selectionList.length == 0"
  255. >导入</el-button
  256. >
  257. </span>
  258. </el-dialog>
  259. <report-dialog
  260. :switchDialog="switchDialog"
  261. :reportId="form.id"
  262. reportName="客户询价"
  263. @onClose="onClose()"
  264. ></report-dialog>
  265. </div>
  266. </template>
  267. <script>
  268. import tableOption from "./config/customerContact.json";
  269. import goodsOption from "./config/commodity.json";
  270. import {
  271. detail,
  272. submit,
  273. delItem,
  274. getDeptLazyTree,
  275. getGoods,
  276. getSpecification,
  277. submitMessage
  278. } from "@/api/basicData/purchaseInquiry";
  279. import customerDialog from "@/components/customer-dialog/main";
  280. import reportDialog from "@/components/report-dialog/main";
  281. import { micrometerFormat } from "@/util/validate";
  282. import { contrastObj, contrastList } from "@/util/contrastData";
  283. import {
  284. productCal,
  285. sellingCal,
  286. amountCal,
  287. transformCal,
  288. purchaseCal
  289. } from "@/util/calculate";
  290. import _ from "lodash";
  291. export default {
  292. name: "detailsPageEdit",
  293. data() {
  294. return {
  295. switchDialog: false,
  296. form: {
  297. orderStatus: "录入",
  298. currency: "CNY",
  299. exchangeRate: "1"
  300. },
  301. disabled: false,
  302. dialogVisible: false,
  303. tableOption: {},
  304. option: {
  305. menuBtn: false,
  306. labelWidth: 100,
  307. disabled: false,
  308. column: [
  309. {
  310. label: "客户名称",
  311. prop: "corpId",
  312. span: 16
  313. },
  314. {
  315. label: "系统号",
  316. prop: "sysNo",
  317. span: 8
  318. },
  319. {
  320. label: "订单状态",
  321. prop: "orderStatus",
  322. span: 8,
  323. type: "select",
  324. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  325. props: {
  326. label: "dictValue",
  327. value: "dictValue"
  328. },
  329. disabled: true
  330. },
  331. {
  332. label: "询价日期",
  333. prop: "businesDate",
  334. span: 8,
  335. type: "date",
  336. format: "yyyy-MM-dd",
  337. valueFormat: "yyyy-MM-dd 00:00:00",
  338. rules: [
  339. {
  340. required: true,
  341. message: "",
  342. trigger: "blur"
  343. }
  344. ]
  345. },
  346. {
  347. label: "有效日期",
  348. prop: "dateValidity",
  349. span: 8,
  350. type: "date",
  351. format: "yyyy-MM-dd",
  352. valueFormat: "yyyy-MM-dd 00:00:00",
  353. rules: [
  354. {
  355. required: true,
  356. message: "",
  357. trigger: "blur"
  358. }
  359. ]
  360. },
  361. {
  362. label: "订单号",
  363. prop: "orderNo",
  364. span: 8
  365. },
  366. {
  367. label: "币别",
  368. prop: "currency",
  369. span: 8,
  370. type: "select",
  371. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  372. props: {
  373. label: "dictValue",
  374. value: "dictValue"
  375. },
  376. change: ({ value }) => {
  377. if (value == "CNY") {
  378. this.form.exchangeRate = 1;
  379. }
  380. if (value == "USD") {
  381. this.form.exchangeRate = 6.3843;
  382. }
  383. },
  384. disabled: true
  385. },
  386. {
  387. label: "汇率",
  388. prop: "exchangeRate",
  389. span: 8,
  390. slot: true,
  391. row: true,
  392. disabled: true
  393. },
  394. {
  395. label: "备注",
  396. prop: "orderRemark",
  397. type: "textarea",
  398. minRows: 2,
  399. span: 8
  400. },
  401. {
  402. label: "采购备注",
  403. prop: "purchaseRemark",
  404. type: "textarea",
  405. minRows: 2,
  406. span: 8
  407. },
  408. {
  409. label: "船务备注",
  410. prop: "shippingRemark",
  411. type: "textarea",
  412. minRows: 2,
  413. span: 8
  414. }
  415. ]
  416. },
  417. treeOption: {
  418. nodeKey: "id",
  419. lazy: true,
  420. treeLoad: function(node, resolve) {
  421. const parentId = node.level === 0 ? 0 : node.data.id;
  422. getDeptLazyTree(parentId).then(res => {
  423. resolve(
  424. res.data.data.map(item => {
  425. return {
  426. ...item,
  427. leaf: !item.hasChildren
  428. };
  429. })
  430. );
  431. });
  432. },
  433. addBtn: false,
  434. menu: false,
  435. size: "small",
  436. props: {
  437. label: "title",
  438. value: "value",
  439. children: "children"
  440. }
  441. },
  442. page: {
  443. pageSize: 10,
  444. currentPage: 1,
  445. total: 0
  446. },
  447. loading: false,
  448. goodsOption: {},
  449. data: [],
  450. goodsList: [],
  451. selectionList: [],
  452. treeDeptId: null,
  453. itemtypeList: [],
  454. reData: null,
  455. oldform: {
  456. orderStatus: "录入",
  457. currency: "CNY",
  458. exchangeRate: "1"
  459. },
  460. olddata: [],
  461. subLoading: false,
  462. pageLoading: false,
  463. showBut: true,
  464. goodsoptions: [],
  465. currencyList: []
  466. };
  467. },
  468. props: {
  469. detailData: {
  470. type: Object
  471. }
  472. },
  473. components: {
  474. reportDialog,
  475. customerDialog
  476. },
  477. async created() {
  478. if (this.detailData.id) {
  479. this.getDetail(this.detailData.id);
  480. }
  481. this.tableOption = await this.getColumnData(
  482. this.getColumnName(11),
  483. tableOption
  484. );
  485. this.goodsOption = await this.getColumnData(
  486. this.getColumnName(31),
  487. goodsOption
  488. );
  489. if (this.detailData.status == 1) {
  490. this.option.disabled = true;
  491. }
  492. this.getWorkDicts("product_properties").then(res => {
  493. this.findObject(this.tableOption.column, "itemProp").dicData =
  494. res.data.data;
  495. });
  496. this.getWorkDicts("unit").then(res => {
  497. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  498. });
  499. this.getWorkDicts("currency").then(res => {
  500. this.currencyList = res.data.data;
  501. });
  502. getGoods(1, 500).then(res => {
  503. this.goodsoptions = res.data.data.records;
  504. });
  505. },
  506. methods: {
  507. cellStyle() {
  508. return "padding:0;height:40px;";
  509. },
  510. rowCorpData(row) {
  511. this.data[row.index].corpName = row.cname;
  512. },
  513. rePick(row, index) {
  514. this.reData = {
  515. ...row,
  516. index: index
  517. };
  518. this.newDetails();
  519. },
  520. cnameChange(row) {
  521. this.goodsoptions.forEach(e => {
  522. if (e.cname == row.cname) {
  523. row.itemId = e.id;
  524. row.code = e.code;
  525. row.priceCategory = e.goodsTypeName;
  526. row.itemUrl = e.url;
  527. row.itemDescription = e.cnameDescription;
  528. row.unit = e.unit;
  529. }
  530. });
  531. },
  532. rowCell(row, index) {
  533. if (row.$cellEdit == true) {
  534. this.$set(row, "$cellEdit", false);
  535. } else {
  536. this.$set(row, "$cellEdit", true);
  537. }
  538. },
  539. itemTypeFocus(row) {
  540. this.itemtypeList = [];
  541. getSpecification({ goodId: row.itemId }).then(res => {
  542. const data = res.data.data;
  543. this.itemtypeList = data.map(item => ({ value: item }));
  544. });
  545. },
  546. priceChange(row) {
  547. row.purchaseAmount = purchaseCal(row.price, row.taxRate, row.coefficient);
  548. row.amount = Number(
  549. _.multiply(Number(row.purchaseAmount), row.orderQuantity)
  550. ).toFixed(2);
  551. },
  552. quantityChange(row) {
  553. if (!row.orderQuantity) {
  554. row.orderQuantity = 0;
  555. } else {
  556. row.amount = _.multiply(row.purchaseAmount, row.orderQuantity).toFixed(
  557. 2
  558. );
  559. }
  560. },
  561. rowSave(row) {
  562. console.log(row);
  563. this.$set(row, "$cellEdit", false);
  564. },
  565. rowDel(row, index) {
  566. if (row.id) {
  567. delItem(row.id).then(res => {
  568. this.$message({
  569. type: "success",
  570. message: "操作成功!"
  571. });
  572. this.data.splice(index, 1);
  573. });
  574. } else {
  575. this.$message({
  576. type: "success",
  577. message: "操作成功!"
  578. });
  579. this.data.splice(index, 1);
  580. }
  581. },
  582. importGoods() {
  583. if (this.reData) {
  584. console.log(this.reData);
  585. if (this.selectionList.length != 1) {
  586. return this.$message.error("重新选择的时候只能选择一条数据");
  587. } else {
  588. this.selectionList.forEach(e => {
  589. this.data.forEach((item, index) => {
  590. if (index == this.reData.index) {
  591. item.itemId = e.id;
  592. item.code = e.code;
  593. item.cname = e.cname;
  594. item.priceCategory = e.goodsTypeName;
  595. item.itemUrl = e.url;
  596. item.itemProp = this.reData.itemProp;
  597. item.itemDescription = e.cnameDescription;
  598. item.itemType = this.reData.itemType;
  599. item.tradeTerms = this.reData.tradeTerms;
  600. item.price = this.reData.price;
  601. item.orderQuantity = this.reData.orderQuantity;
  602. item.insurance = this.reData.insurance;
  603. item.freight = this.reData.freight;
  604. item.discount = this.reData.discount;
  605. item.amount = this.reData.amount;
  606. item.taxRate = this.reData.taxRate;
  607. item.unit = e.unit;
  608. item.remarks = this.reData.remarks;
  609. item.coefficient = this.reData.coefficient;
  610. item.purchaseAmount = this.reData.purchaseAmount;
  611. item.exchangeRate = this.reData.exchangeRate;
  612. item.currency = this.reData.currency;
  613. item.taxRate = this.reData.taxRate;
  614. item.corpId = this.reData.corpId;
  615. item.priorityReferrer = this.reData.priorityReferrer;
  616. item.$cellEdit = true;
  617. }
  618. });
  619. });
  620. }
  621. } else {
  622. this.selectionList.forEach(e => {
  623. this.data.push({
  624. itemId: e.id,
  625. code: e.code,
  626. cname: e.cname,
  627. priceCategory: e.goodsTypeName,
  628. itemUrl: e.url,
  629. itemProp: null,
  630. corpId: null,
  631. priorityReferrer: 0,
  632. itemDescription: e.cnameDescription,
  633. itemType: null,
  634. tradeTerms: null,
  635. price: 0,
  636. orderQuantity: 0,
  637. insurance: 0,
  638. freight: 0,
  639. discount: null,
  640. amount: 0,
  641. coefficient: 0,
  642. purchaseAmount: 0,
  643. exchangeRate: 1,
  644. currency: "CNY",
  645. taxRate: 0,
  646. unit: e.unit,
  647. remarks: null,
  648. $cellEdit: true
  649. });
  650. });
  651. }
  652. this.dialogVisible = false;
  653. },
  654. closeGoods() {
  655. this.selectionList = [];
  656. this.treeDeptId = "";
  657. this.reData = null;
  658. },
  659. selectionChange(list) {
  660. this.selectionList = list;
  661. },
  662. rowClick(row) {
  663. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  664. },
  665. nodeClick(data) {
  666. this.treeDeptId = data.id;
  667. this.page.currentPage = 1;
  668. this.onLoad(this.page);
  669. },
  670. //费用查询
  671. onLoad(page, params = {}) {
  672. this.loading = true;
  673. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  674. const data = res.data.data;
  675. this.page.total = data.total;
  676. this.goodsList = data.records;
  677. this.loading = false;
  678. if (this.page.total) {
  679. this.goodsOption.height = window.innerHeight - 350;
  680. }
  681. });
  682. },
  683. //商品明细导入
  684. newDetails() {
  685. this.dialogVisible = !this.dialogVisible;
  686. },
  687. getDetail(id) {
  688. this.showBut = false;
  689. this.pageLoading = true;
  690. detail(id)
  691. .then(res => {
  692. this.form = res.data.data;
  693. this.data = res.data.data.orderItemsList
  694. ? res.data.data.orderItemsList
  695. : [];
  696. this.oldform = res.data.data;
  697. this.olddata = this.deepClone(
  698. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  699. );
  700. })
  701. .finally(() => {
  702. this.showBut = true;
  703. this.pageLoading = false;
  704. });
  705. },
  706. //修改提交触发
  707. editCustomer(status, status2) {
  708. this.$refs["form"].validate((valid, done) => {
  709. done();
  710. if (valid) {
  711. if (this.data) {
  712. for (let i = 0; i < this.data.length; i++) {
  713. if (!this.data[i].price || this.data[i].price == "0") {
  714. return this.$message.error(
  715. "第" + (Number(i) + 1) + "行的单价不能为空或不能为0"
  716. );
  717. }
  718. if (this.data[i].taxRate == "") {
  719. return this.$message.error(
  720. "第" + (Number(i) + 1) + "行的税率不能为空"
  721. );
  722. }
  723. if (this.data[i].coefficient == "") {
  724. return this.$message.error(
  725. "第" + (Number(i) + 1) + "行的FOB系数不能为空"
  726. );
  727. }
  728. if (!this.data[i].corpId) {
  729. return this.$message.error(
  730. "第" + (Number(i) + 1) + "行的供应商不能为空"
  731. );
  732. }
  733. }
  734. }
  735. if (status == "save") {
  736. this.subLoading = true;
  737. submit({
  738. ...this.form,
  739. orderItemsList: this.data
  740. })
  741. .then(res => {
  742. this.form = res.data.data;
  743. this.data = res.data.data.orderItemsList
  744. ? res.data.data.orderItemsList
  745. : [];
  746. this.$message.success("修改成功");
  747. this.oldform = res.data.data;
  748. this.olddata = this.deepClone(
  749. res.data.data.orderItemsList
  750. ? res.data.data.orderItemsList
  751. : []
  752. );
  753. if (status2 == "goBack") {
  754. this.$emit("goBack");
  755. }
  756. })
  757. .finally(() => {
  758. this.subLoading = false;
  759. });
  760. }
  761. if (status == "submit") {
  762. if (this.data.length == 0) {
  763. return this.$message.error("明细表不能为空");
  764. }
  765. submitMessage({
  766. ...this.form,
  767. orderItemsList: this.data
  768. }).then(res => {
  769. this.form = res.data.data;
  770. this.data = res.data.data.orderItemsList
  771. ? res.data.data.orderItemsList
  772. : [];
  773. this.$message.success("提交成功");
  774. this.oldform = res.data.data;
  775. this.olddata = this.deepClone(
  776. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  777. );
  778. });
  779. }
  780. } else {
  781. return false;
  782. }
  783. });
  784. },
  785. //返回列表
  786. backToList() {
  787. if (
  788. contrastObj(this.form, this.oldform) ||
  789. contrastList(this.data, this.olddata)
  790. ) {
  791. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  792. confirmButtonText: "确定",
  793. cancelButtonText: "取消",
  794. type: "warning"
  795. })
  796. .then(() => {
  797. this.editCustomer("save", "goBack");
  798. })
  799. .catch(() => {
  800. this.$emit("goBack");
  801. });
  802. } else {
  803. this.$emit("goBack");
  804. }
  805. },
  806. openReport() {
  807. this.switchDialog = !this.switchDialog;
  808. },
  809. onClose(val) {
  810. this.switchDialog = val;
  811. },
  812. summaryMethod({ columns, data }) {
  813. const sums = [];
  814. if (columns.length > 0) {
  815. columns.forEach((item, index) => {
  816. sums[0] = "合计";
  817. if (item.property == "orderQuantity" || item.property == "amount") {
  818. let qtySum = 0;
  819. let amountSum = 0;
  820. data.forEach(e => {
  821. qtySum = _.add(qtySum, Number(e.orderQuantity));
  822. amountSum = _.add(amountSum, Number(e.amount));
  823. });
  824. //数量总计
  825. if (item.property == "orderQuantity") {
  826. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  827. }
  828. //金额总计
  829. if (item.property == "amount") {
  830. sums[index] = micrometerFormat(amountSum);
  831. }
  832. }
  833. });
  834. }
  835. return sums;
  836. },
  837. async saveColumn() {
  838. const inSave = await this.saveColumnData(
  839. this.getColumnName(11),
  840. this.tableOption
  841. );
  842. if (inSave) {
  843. this.$message.success("保存成功");
  844. //关闭窗口
  845. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  846. }
  847. },
  848. async saveGoodsColumn() {
  849. const inSave = await this.saveColumnData(
  850. this.getColumnName(31),
  851. this.goodsOption
  852. );
  853. if (inSave) {
  854. this.$message.success("保存成功");
  855. //关闭窗口
  856. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  857. }
  858. }
  859. }
  860. };
  861. </script>
  862. <style lang="scss" scoped>
  863. .trading-form ::v-deep .el-form-item {
  864. margin-bottom: 8px !important;
  865. }
  866. ::v-deep .el-form-item__error {
  867. display: none !important;
  868. }
  869. ::v-deep .select-component {
  870. display: flex !important;
  871. }
  872. </style>