detailsPage.vue 28 KB

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