detailsPage.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  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)"
  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. :search.sync="search"
  271. @search-change="searchChange"
  272. @refresh-change="refreshChange"
  273. @selection-change="selectionChange"
  274. @row-click="rowClick"
  275. :page.sync="page"
  276. @on-load="onLoad"
  277. @saveColumn="saveGoodsColumn"
  278. @resetColumn="resetGoodsColumn"
  279. :cell-style="cellStyle"
  280. ></avue-crud>
  281. </el-col>
  282. </el-row>
  283. </span>
  284. <span slot="footer" class="dialog-footer">
  285. <el-button @click="dialogVisible = false">取 消</el-button>
  286. <el-button
  287. type="primary"
  288. @click="importGoods"
  289. :disabled="selectionList.length == 0"
  290. >导入</el-button
  291. >
  292. </span>
  293. </el-dialog>
  294. <report-dialog
  295. :switchDialog="switchDialog"
  296. :reportId="form.id"
  297. reportName="客户询价"
  298. @onClose="onClose()"
  299. ></report-dialog>
  300. </div>
  301. </template>
  302. <script>
  303. import tableOption from "./config/customerContact.json";
  304. import goodsOption from "./config/commodity.json";
  305. import {
  306. detail,
  307. submit,
  308. delItem,
  309. getDeptLazyTree,
  310. getGoods,
  311. getSpecification,
  312. submitMessage
  313. } from "@/api/basicData/purchaseInquiry";
  314. import customerDialog from "@/components/customer-dialog/main";
  315. import reportDialog from "@/components/report-dialog/main";
  316. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  317. import { contrastObj, contrastList } from "@/util/contrastData";
  318. import { purchaseCal } from "@/util/calculate";
  319. import _ from "lodash";
  320. export default {
  321. name: "detailsPageEdit",
  322. data() {
  323. return {
  324. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  325. switchDialog: false,
  326. form: {
  327. orderStatus: "录入",
  328. currency: "CNY",
  329. exchangeRate: "1"
  330. },
  331. disabled: false,
  332. dialogVisible: false,
  333. tableOption: {},
  334. option: {
  335. menuBtn: false,
  336. labelWidth: 100,
  337. disabled: false,
  338. column: [
  339. {
  340. label: "客户名称",
  341. prop: "corpId",
  342. span: 16
  343. },
  344. {
  345. label: "系统号",
  346. prop: "sysNo",
  347. span: 8,
  348. disabled: true
  349. },
  350. {
  351. label: "是否询价",
  352. prop: "ifEnquiry",
  353. span: 8,
  354. disabled: true
  355. },
  356. {
  357. label: "询价日期",
  358. prop: "businesDate",
  359. span: 8,
  360. type: "date",
  361. format: "yyyy-MM-dd",
  362. valueFormat: "yyyy-MM-dd 00:00:00",
  363. rules: [
  364. {
  365. required: true,
  366. message: "",
  367. trigger: "blur"
  368. }
  369. ]
  370. },
  371. {
  372. label: "有效日期",
  373. prop: "dateValidity",
  374. span: 8,
  375. rules: [
  376. {
  377. required: true,
  378. message: "",
  379. trigger: "blur"
  380. }
  381. ]
  382. },
  383. {
  384. label: "订单号",
  385. prop: "orderNo",
  386. span: 8
  387. },
  388. {
  389. label: "币别",
  390. prop: "currency",
  391. span: 8,
  392. type: "select",
  393. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  394. props: {
  395. label: "dictValue",
  396. value: "dictValue"
  397. },
  398. change: ({ value }) => {
  399. if (value == "CNY") {
  400. this.form.exchangeRate = 1;
  401. }
  402. if (value == "USD") {
  403. this.form.exchangeRate = 6.3843;
  404. }
  405. },
  406. disabled: true
  407. },
  408. {
  409. label: "汇率",
  410. prop: "exchangeRate",
  411. span: 8,
  412. slot: true,
  413. row: true,
  414. disabled: true
  415. },
  416. {
  417. label: "备注",
  418. prop: "orderRemark",
  419. type: "textarea",
  420. minRows: 2,
  421. span: 8
  422. },
  423. {
  424. label: "采购备注",
  425. prop: "purchaseRemark",
  426. type: "textarea",
  427. minRows: 2,
  428. span: 8
  429. },
  430. {
  431. label: "船务备注",
  432. prop: "shippingRemark",
  433. type: "textarea",
  434. minRows: 2,
  435. span: 8
  436. }
  437. ]
  438. },
  439. treeOption: {
  440. nodeKey: "id",
  441. lazy: true,
  442. treeLoad: function(node, resolve) {
  443. const parentId = node.level === 0 ? 0 : node.data.id;
  444. getDeptLazyTree(parentId).then(res => {
  445. resolve(
  446. res.data.data.map(item => {
  447. return {
  448. ...item,
  449. leaf: !item.hasChildren
  450. };
  451. })
  452. );
  453. });
  454. },
  455. addBtn: false,
  456. menu: false,
  457. size: "small",
  458. props: {
  459. label: "title",
  460. value: "value",
  461. children: "children"
  462. }
  463. },
  464. page: {
  465. pageSize: 10,
  466. currentPage: 1,
  467. total: 0
  468. },
  469. loading: false,
  470. goodsOption: {},
  471. data: [],
  472. goodsList: [],
  473. selectionList: [],
  474. treeDeptId: null,
  475. itemtypeList: [],
  476. reData: null,
  477. oldform: {
  478. orderStatus: "录入",
  479. currency: "CNY",
  480. exchangeRate: "1"
  481. },
  482. olddata: [],
  483. subLoading: false,
  484. pageLoading: false,
  485. showBut: true,
  486. goodsoptions: [],
  487. currencyList: [],
  488. search: {}
  489. };
  490. },
  491. props: {
  492. detailData: {
  493. type: Object
  494. }
  495. },
  496. components: {
  497. reportDialog,
  498. customerDialog
  499. },
  500. filters: {
  501. IntegerFormat(num) {
  502. return IntegerFormat(num);
  503. }
  504. },
  505. async created() {
  506. if (this.detailData.id) {
  507. this.getDetail(this.detailData.id);
  508. }
  509. this.tableOption = await this.getColumnData(
  510. this.getColumnName(11),
  511. tableOption
  512. );
  513. this.goodsOption = await this.getColumnData(
  514. this.getColumnName(31),
  515. goodsOption
  516. );
  517. if (this.detailData.status == 1) {
  518. this.option.disabled = true;
  519. }
  520. this.getWorkDicts("product_properties").then(res => {
  521. this.findObject(this.tableOption.column, "itemProp").dicData =
  522. res.data.data;
  523. });
  524. this.getWorkDicts("unit").then(res => {
  525. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  526. });
  527. this.getWorkDicts("currency").then(res => {
  528. this.currencyList = res.data.data;
  529. });
  530. getGoods(1, 500).then(res => {
  531. this.goodsoptions = res.data.data.records;
  532. });
  533. this.pickerOptions = {
  534. disabledDate: time => {
  535. var today = new Date();
  536. today.setTime(today.getTime() - 24 * 60 * 60 * 1000);
  537. return time.getTime() < today.getTime();
  538. }
  539. };
  540. },
  541. methods: {
  542. cellStyle() {
  543. return "padding:0;height:40px;";
  544. },
  545. copyDoc() {
  546. this.$emit("copyOrder", this.form.id);
  547. },
  548. rowCorpData(row) {
  549. this.data[row.index].corpName = row.cname;
  550. },
  551. rePick(row, index) {
  552. this.reData = {
  553. ...row,
  554. index: index
  555. };
  556. this.newDetails();
  557. },
  558. cnameChange(row) {
  559. this.goodsoptions.forEach(e => {
  560. if (e.cname == row.cname) {
  561. row.itemId = e.id;
  562. row.code = e.code;
  563. row.priceCategory = e.goodsTypeName;
  564. row.itemUrl = e.url;
  565. row.itemDescription = e.cnameDescription;
  566. row.unit = e.unit;
  567. }
  568. });
  569. },
  570. rowCell(row, index) {
  571. if (row.$cellEdit == true) {
  572. this.$set(row, "$cellEdit", false);
  573. } else {
  574. this.$set(row, "$cellEdit", true);
  575. }
  576. },
  577. itemTypeFocus(row) {
  578. this.itemtypeList = [];
  579. getSpecification({ goodId: row.itemId }).then(res => {
  580. const data = res.data.data;
  581. this.itemtypeList = data.map(item => ({ value: item }));
  582. });
  583. },
  584. priceChange(row) {
  585. row.purchaseAmount = purchaseCal(row.price, row.taxRate, row.coefficient);
  586. row.amount = Number(
  587. _.multiply(Number(row.purchaseAmount), row.orderQuantity)
  588. ).toFixed(2);
  589. },
  590. quantityChange(row) {
  591. if (!row.orderQuantity) {
  592. row.orderQuantity = 0;
  593. } else {
  594. row.amount = _.multiply(row.purchaseAmount, row.orderQuantity).toFixed(
  595. 2
  596. );
  597. }
  598. },
  599. rowSave(row) {
  600. console.log(row);
  601. this.$set(row, "$cellEdit", false);
  602. },
  603. rowDel(row) {
  604. if (row.id) {
  605. delItem(row.id).then(res => {
  606. this.$message({
  607. type: "success",
  608. message: "操作成功!"
  609. });
  610. this.data.splice(row.$index, 1);
  611. });
  612. } else {
  613. this.$message({
  614. type: "success",
  615. message: "操作成功!"
  616. });
  617. this.data.splice(row.$index, 1);
  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.coefficient = this.reData.coefficient;
  648. item.purchaseAmount = this.reData.purchaseAmount;
  649. item.exchangeRate = this.reData.exchangeRate;
  650. item.currency = this.reData.currency;
  651. item.taxRate = this.reData.taxRate;
  652. item.corpId = this.reData.corpId;
  653. item.priorityReferrer = this.reData.priorityReferrer;
  654. item.$cellEdit = true;
  655. }
  656. });
  657. });
  658. }
  659. } else {
  660. this.selectionList.forEach(e => {
  661. this.data.push({
  662. itemId: e.id,
  663. code: e.code,
  664. cname: e.cname,
  665. priceCategory: e.goodsTypeName,
  666. itemUrl: e.url,
  667. itemProp: null,
  668. corpId: null,
  669. priorityReferrer: 0,
  670. itemDescription: e.cnameDescription,
  671. itemType: null,
  672. tradeTerms: null,
  673. price: 0,
  674. orderQuantity: 0,
  675. insurance: 0,
  676. freight: 0,
  677. discount: null,
  678. amount: 0,
  679. coefficient: 0,
  680. purchaseAmount: 0,
  681. exchangeRate: 1,
  682. currency: "CNY",
  683. taxRate: 0,
  684. unit: e.unit,
  685. remarks: null,
  686. $cellEdit: true
  687. });
  688. });
  689. }
  690. this.dialogVisible = false;
  691. },
  692. closeGoods() {
  693. this.selectionList = [];
  694. this.treeDeptId = "";
  695. this.reData = null;
  696. },
  697. selectionChange(list) {
  698. this.selectionList = list;
  699. },
  700. rowClick(row) {
  701. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  702. },
  703. nodeClick(data) {
  704. this.treeDeptId = data.id;
  705. this.page.currentPage = 1;
  706. this.onLoad(this.page);
  707. },
  708. searchChange(params, done) {
  709. this.search = this.deepClone(params);
  710. this.onLoad(this.page, params);
  711. done();
  712. },
  713. //费用查询
  714. onLoad(page, params = {}) {
  715. let obj = this.deepClone(Object.assign(params, this.search));
  716. this.loading = true;
  717. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj).then(
  718. res => {
  719. const data = res.data.data;
  720. this.page.total = data.total;
  721. this.goodsList = data.records;
  722. this.loading = false;
  723. if (this.page.total) {
  724. this.goodsOption.height = window.innerHeight - 350;
  725. }
  726. }
  727. );
  728. },
  729. //商品明细导入
  730. newDetails() {
  731. this.dialogVisible = !this.dialogVisible;
  732. },
  733. getDetail(id) {
  734. this.showBut = false;
  735. this.pageLoading = true;
  736. detail(id)
  737. .then(res => {
  738. if (this.detailData.status == "copy") {
  739. delete res.data.data.id;
  740. delete res.data.data.sysNo;
  741. delete res.data.data.orderNo;
  742. delete res.data.data.orgOrderNo;
  743. delete res.data.data.createTime;
  744. delete res.data.data.createUser;
  745. delete res.data.data.createUserName;
  746. delete res.data.data.updateTime;
  747. delete res.data.data.updateUser;
  748. delete res.data.data.updateUserName;
  749. delete res.data.data.morderNo;
  750. delete res.data.data.status;
  751. delete res.data.data.ifEnquiry;
  752. delete res.data.data.ifShipping;
  753. res.data.data.orderStatus = "录入";
  754. if (res.data.data.orderItemsList) {
  755. res.data.data.orderItemsList.forEach(e => {
  756. delete e.id;
  757. delete e.pid;
  758. delete e.createTime;
  759. delete e.createUser;
  760. delete e.updateTime;
  761. delete e.updateUser;
  762. delete e.status;
  763. delete e.isDeleted;
  764. });
  765. }
  766. }
  767. this.form = res.data.data;
  768. this.data = res.data.data.orderItemsList
  769. ? res.data.data.orderItemsList
  770. : [];
  771. this.oldform = res.data.data;
  772. this.olddata = this.deepClone(
  773. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  774. );
  775. })
  776. .finally(() => {
  777. this.showBut = true;
  778. this.pageLoading = false;
  779. });
  780. },
  781. //修改提交触发
  782. editCustomer(status, status2) {
  783. this.$refs["form"].validate((valid, done) => {
  784. done();
  785. if (valid) {
  786. if (this.data) {
  787. for (let i = 0; i < this.data.length; i++) {
  788. if (!this.data[i].price || this.data[i].price == "0") {
  789. return this.$message.error(
  790. "第" + (Number(i) + 1) + "行的单价不能为空或不能为0"
  791. );
  792. }
  793. if (
  794. this.data[i].taxRate == null ||
  795. this.data[i].taxRate == undefined ||
  796. this.data[i].taxRate === ""
  797. ) {
  798. return this.$message.error(
  799. "第" + (Number(i) + 1) + "行的税率不能为空"
  800. );
  801. }
  802. if (
  803. this.data[i].coefficient == null ||
  804. this.data[i].coefficient == undefined ||
  805. this.data[i].coefficient === ""
  806. ) {
  807. return this.$message.error(
  808. "第" + (Number(i) + 1) + "行的FOB系数不能为空"
  809. );
  810. }
  811. if (!this.data[i].corpId) {
  812. return this.$message.error(
  813. "第" + (Number(i) + 1) + "行的供应商不能为空"
  814. );
  815. }
  816. }
  817. }
  818. if (status == "save") {
  819. this.subLoading = true;
  820. submit({
  821. ...this.form,
  822. orderItemsList: this.data
  823. })
  824. .then(res => {
  825. this.form = res.data.data;
  826. this.data = res.data.data.orderItemsList
  827. ? res.data.data.orderItemsList
  828. : [];
  829. this.$message.success("保存成功");
  830. this.oldform = res.data.data;
  831. this.olddata = this.deepClone(
  832. res.data.data.orderItemsList
  833. ? res.data.data.orderItemsList
  834. : []
  835. );
  836. if (status2 == "goBack") {
  837. if (this.form.id) {
  838. this.unLock({
  839. moduleName: "xj",
  840. tableName: "business_order",
  841. billId: this.form.id,
  842. billNo: this.form.orgOrderNo
  843. });
  844. }
  845. this.$emit("goBack");
  846. this.leaveDetailsKey(this.$route.name);
  847. }
  848. })
  849. .finally(() => {
  850. this.subLoading = false;
  851. });
  852. }
  853. if (status == "submit") {
  854. if (this.data.length == 0) {
  855. return this.$message.error("明细表不能为空");
  856. }
  857. submitMessage({
  858. ...this.form,
  859. orderItemsList: this.data
  860. }).then(res => {
  861. this.form = res.data.data;
  862. this.data = res.data.data.orderItemsList
  863. ? res.data.data.orderItemsList
  864. : [];
  865. this.$message.success("提交成功");
  866. this.oldform = res.data.data;
  867. this.olddata = this.deepClone(
  868. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  869. );
  870. this.option.disabled = true;
  871. });
  872. }
  873. } else {
  874. return false;
  875. }
  876. });
  877. },
  878. //返回列表
  879. backToList() {
  880. if (
  881. contrastObj(this.form, this.oldform) ||
  882. contrastList(this.data, this.olddata)
  883. ) {
  884. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  885. confirmButtonText: "确定",
  886. cancelButtonText: "取消",
  887. type: "warning"
  888. })
  889. .then(() => {
  890. this.editCustomer("save", "goBack");
  891. })
  892. .catch(() => {
  893. if (this.form.id) {
  894. this.unLock({
  895. moduleName: "xj",
  896. tableName: "business_order",
  897. billId: this.form.id,
  898. billNo: this.form.orgOrderNo
  899. });
  900. }
  901. this.$emit("goBack");
  902. this.leaveDetailsKey(this.$route.name);
  903. });
  904. } else {
  905. if (this.form.id) {
  906. this.unLock({
  907. moduleName: "xj",
  908. tableName: "business_order",
  909. billId: this.form.id,
  910. billNo: this.form.orgOrderNo
  911. });
  912. }
  913. this.$emit("goBack");
  914. this.leaveDetailsKey(this.$route.name);
  915. }
  916. },
  917. openReport() {
  918. this.switchDialog = !this.switchDialog;
  919. },
  920. onClose(val) {
  921. this.switchDialog = val;
  922. },
  923. summaryMethod({ columns, data }) {
  924. const sums = [];
  925. if (columns.length > 0) {
  926. columns.forEach((item, index) => {
  927. sums[0] = "合计";
  928. if (item.property == "orderQuantity" || item.property == "amount") {
  929. let qtySum = 0;
  930. let amountSum = 0;
  931. data.forEach(e => {
  932. qtySum = _.add(qtySum, Number(e.orderQuantity));
  933. amountSum = _.add(amountSum, Number(e.amount));
  934. });
  935. //数量总计
  936. if (item.property == "orderQuantity") {
  937. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  938. }
  939. //金额总计
  940. if (item.property == "amount") {
  941. sums[index] = micrometerFormat(amountSum);
  942. }
  943. }
  944. });
  945. }
  946. return sums;
  947. },
  948. openEdit() {
  949. const data = {
  950. moduleName: "xj",
  951. tableName: "business_order",
  952. billId: this.form.id,
  953. no: localStorage.getItem("browserID"),
  954. billNo: this.form.orgOrderNo
  955. };
  956. this.inDetailsKey(this.$route.name, {
  957. moduleName: "xj",
  958. tableName: "business_order",
  959. billId: this.form.id,
  960. billNo: this.form.orgOrderNo
  961. });
  962. this.checkLock(data).then(res => {
  963. if (res.data.code == 200) {
  964. this.onLock(data).then(res => {
  965. if (res.data.code == 200) {
  966. this.detailData.status = 2;
  967. this.option = this.$options.data().option;
  968. }
  969. });
  970. }
  971. });
  972. },
  973. async saveColumn() {
  974. const inSave = await this.saveColumnData(
  975. this.getColumnName(11),
  976. this.tableOption
  977. );
  978. if (inSave) {
  979. this.$message.success("保存成功");
  980. //关闭窗口
  981. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  982. }
  983. },
  984. async resetColumn() {
  985. this.tableOption = tableOption;
  986. const inSave = await this.delColumnData(
  987. this.getColumnName(11),
  988. tableOption
  989. );
  990. if (inSave) {
  991. this.$message.success("重置成功");
  992. //关闭窗口
  993. setTimeout(() => {
  994. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  995. }, 1000);
  996. }
  997. },
  998. async saveGoodsColumn() {
  999. const inSave = await this.saveColumnData(
  1000. this.getColumnName(31),
  1001. this.goodsOption
  1002. );
  1003. if (inSave) {
  1004. this.$message.success("保存成功");
  1005. //关闭窗口
  1006. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1007. }
  1008. },
  1009. async resetGoodsColumn() {
  1010. this.goodsOption = goodsOption;
  1011. const inSave = await this.delColumnData(
  1012. this.getColumnName(31),
  1013. goodsOption
  1014. );
  1015. if (inSave) {
  1016. this.$message.success("重置成功");
  1017. //关闭窗口
  1018. setTimeout(() => {
  1019. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1020. }, 1000);
  1021. }
  1022. }
  1023. }
  1024. };
  1025. </script>
  1026. <style lang="scss" scoped>
  1027. .trading-form ::v-deep .el-form-item {
  1028. margin-bottom: 8px !important;
  1029. }
  1030. ::v-deep .el-form-item__error {
  1031. display: none !important;
  1032. }
  1033. ::v-deep .select-component {
  1034. display: flex !important;
  1035. }
  1036. </style>