detailsPage.vue 31 KB

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