detailsPage.vue 30 KB

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