detailsPage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. >返回列表
  11. </el-button>
  12. </div>
  13. <div class="add-customer-btn" v-if="showBut">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. v-if="detailData.status == 1"
  18. class="el-button--small-yh "
  19. @click.stop="openEdit"
  20. >编辑
  21. </el-button>
  22. <el-button
  23. type="primary"
  24. :disabled="disabled && detailData.status == 1"
  25. @click="editCustomer('submit')"
  26. v-if="form.id && detailData.status != 1"
  27. :loading="subLoading"
  28. size="small"
  29. >保存数据
  30. </el-button>
  31. <el-button
  32. type="primary"
  33. :disabled="disabled && detailData.status == 1"
  34. v-if="detailData.status != 1"
  35. @click="editCustomer('fix')"
  36. size="small"
  37. >提 交
  38. </el-button>
  39. </div>
  40. </div>
  41. <div class="customer-main">
  42. <containerTitle title="基础信息"></containerTitle>
  43. <basic-container>
  44. <avue-form
  45. class="trading-form"
  46. ref="form"
  47. v-model="form"
  48. :option="option"
  49. >
  50. <template slot="portOfLoad">
  51. <port-info v-model="form.portOfLoad" :disabled="true" />
  52. </template>
  53. <template slot="portOfDestination">
  54. <port-info v-model="form.portOfDestination" :disabled="true" />
  55. </template>
  56. </avue-form>
  57. </basic-container>
  58. <containerTitle title="商品信息"></containerTitle>
  59. <basic-container>
  60. <avue-crud
  61. ref="crud"
  62. :data="data"
  63. :option="tableOption"
  64. @row-del="rowDel"
  65. @saveColumn="saveColumn"
  66. @resetColumn="resetColumn"
  67. :summary-method="summaryMethod"
  68. :cell-style="cellStyle"
  69. >
  70. <template slot-scope="{ row }" slot="orderQuantity">
  71. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  72. </template>
  73. </avue-crud>
  74. </basic-container>
  75. <containerTitle title="运费明细"></containerTitle>
  76. <basic-container>
  77. <avue-crud
  78. ref="freightCrud"
  79. :data="freightData"
  80. :option="freightOption"
  81. @row-del="rowDel"
  82. @saveColumn="saveFreightColumn"
  83. :cell-style="cellStyle"
  84. >
  85. <template slot="shippingHouse" slot-scope="{ row, index }">
  86. <crop-select
  87. v-show="row.$cellEdit"
  88. v-model="row.shippingHouse"
  89. :cropIndex="index"
  90. @getCorpData="rowCorpData"
  91. corpType="GYS"
  92. ></crop-select>
  93. <span v-show="!row.$cellEdit">{{ row.shippingHouseName }}</span>
  94. </template>
  95. <template slot="priorityReferrer" slot-scope="{ row }">
  96. <el-checkbox
  97. :disabled="!row.$cellEdit"
  98. v-model="row.priorityReferrer"
  99. :true-label="1"
  100. :false-label="0"
  101. />
  102. </template>
  103. <template slot="oceanFreight" slot-scope="{ row }">
  104. <el-input
  105. size="small"
  106. v-model="row.oceanFreight"
  107. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  108. placeholder="请输入"
  109. :disabled="detailData.status == 1"
  110. v-if="row.$cellEdit"
  111. />
  112. <span v-else>{{ row.oceanFreight }}</span>
  113. </template>
  114. <template slot="menu" slot-scope="{ row, index }">
  115. <el-button
  116. size="small"
  117. icon="el-icon-edit"
  118. type="text"
  119. @click="rowCell(row, index)"
  120. :disabled="disabled"
  121. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  122. >
  123. <el-button
  124. size="small"
  125. icon="el-icon-edit"
  126. type="text"
  127. @click="rowDel(row, index)"
  128. :disabled="detailData.status == 1"
  129. >删 除</el-button
  130. >
  131. </template>
  132. <template slot="menuLeft">
  133. <el-button
  134. type="primary"
  135. icon="el-icon-plus"
  136. size="small"
  137. @click.stop="addFreight"
  138. :disabled="detailData.status == 1"
  139. >新增</el-button
  140. ></template
  141. >
  142. </avue-crud>
  143. </basic-container>
  144. </div>
  145. <el-dialog
  146. title="导入商品"
  147. append-to-body
  148. class="el-dialogDeep"
  149. :visible.sync="dialogVisible"
  150. width="80%"
  151. :close-on-click-modal="false"
  152. :destroy-on-close="true"
  153. :close-on-press-escape="false"
  154. @close="closeGoods"
  155. top="5vh"
  156. v-dialog-drag
  157. >
  158. <span>
  159. <el-row>
  160. <el-col :span="4">
  161. <div>
  162. <el-scrollbar>
  163. <basic-container>
  164. <avue-tree
  165. :option="treeOption"
  166. @node-click="nodeClick"
  167. :style="treeStyle"
  168. />
  169. </basic-container>
  170. </el-scrollbar>
  171. </div>
  172. </el-col>
  173. <el-col :span="20">
  174. <avue-crud
  175. :option="goodsOption"
  176. :table-loading="loading"
  177. :data="goodsList"
  178. ref="goodsCrud"
  179. :search.sync="search"
  180. @search-change="searchChange"
  181. @refresh-change="refreshChange"
  182. @selection-change="selectionChange"
  183. @row-click="rowClick"
  184. :page.sync="page"
  185. @on-load="onLoad"
  186. @saveColumn="saveGoodsColumn"
  187. @resetColumn="resetGoodsColumn"
  188. :cell-style="cellStyle"
  189. ></avue-crud>
  190. </el-col>
  191. </el-row>
  192. </span>
  193. <span slot="footer" class="dialog-footer">
  194. <el-button @click="dialogVisible = false">取 消</el-button>
  195. <el-button
  196. type="primary"
  197. @click="importGoods"
  198. :disabled="selectionList.length == 0"
  199. >导入</el-button
  200. >
  201. </span>
  202. </el-dialog>
  203. <report-dialog
  204. :switchDialog="switchDialog"
  205. :reportId="form.id"
  206. reportName="客户询价"
  207. @onClose="onClose()"
  208. ></report-dialog>
  209. </div>
  210. </template>
  211. <script>
  212. import tableOption from "./config/customerContact.json";
  213. import goodsOption from "./config/commodity.json";
  214. import freightOption from "./config/freight.json";
  215. import customerDialog from "@/components/customer-dialog/main";
  216. import {
  217. detail,
  218. submit,
  219. getDeptLazyTree,
  220. getGoods,
  221. getPorts,
  222. delItem,
  223. commit
  224. } from "@/api/basicData/shippingInquiry";
  225. import reportDialog from "@/components/report-dialog/main";
  226. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  227. import { contrastObj, contrastList } from "@/util/contrastData";
  228. import _ from "lodash";
  229. export default {
  230. name: "detailsPageEdit",
  231. data() {
  232. return {
  233. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  234. switchDialog: false,
  235. form: {},
  236. disabled: false,
  237. dialogVisible: false,
  238. freightOption: freightOption,
  239. tableOption: {},
  240. option: {
  241. menuBtn: false,
  242. labelWidth: 100,
  243. disabled: true,
  244. column: [
  245. {
  246. label: "系统号",
  247. prop: "sysNo",
  248. span: 8
  249. },
  250. {
  251. label: "起运港",
  252. prop: "portOfLoad",
  253. span: 8,
  254. type: "select",
  255. filterable: true,
  256. dicData: [],
  257. props: {
  258. label: "name",
  259. value: "name"
  260. }
  261. },
  262. {
  263. label: "目的港",
  264. prop: "portOfDestination",
  265. span: 8,
  266. type: "select",
  267. filterable: true,
  268. dicData: [],
  269. props: {
  270. label: "name",
  271. value: "name"
  272. }
  273. },
  274. {
  275. label: "订单号",
  276. prop: "orderNo",
  277. span: 8
  278. },
  279. {
  280. label: "计划交期",
  281. prop: "plannedDeliveryDate",
  282. span: 8,
  283. type: "date",
  284. format: "yyyy-MM-dd",
  285. valueFormat: "yyyy-MM-dd 00:00:00",
  286. row: true
  287. },
  288. {
  289. label: "箱型",
  290. prop: "boxPile",
  291. type: "select",
  292. dicUrl: "/api/blade-system/dict-biz/dictionary?code=boxType",
  293. props: {
  294. label: "dictValue",
  295. value: "dictValue"
  296. },
  297. span: 8
  298. },
  299. {
  300. label: "箱量",
  301. prop: "boxNumber",
  302. span: 8
  303. },
  304. {
  305. label: "起订量",
  306. prop: "minOrder",
  307. span: 8
  308. },
  309. {
  310. label: "销售指示",
  311. prop: "orderRemark",
  312. type: "textarea",
  313. minRows: 2,
  314. span: 24
  315. }
  316. ]
  317. },
  318. treeOption: {
  319. nodeKey: "id",
  320. lazy: true,
  321. treeLoad: function(node, resolve) {
  322. const parentId = node.level === 0 ? 0 : node.data.id;
  323. getDeptLazyTree(parentId).then(res => {
  324. resolve(
  325. res.data.data.map(item => {
  326. return {
  327. ...item,
  328. leaf: !item.hasChildren
  329. };
  330. })
  331. );
  332. });
  333. },
  334. addBtn: false,
  335. menu: false,
  336. size: "small",
  337. props: {
  338. label: "title",
  339. value: "value",
  340. children: "children"
  341. }
  342. },
  343. page: {
  344. pageSize: 10,
  345. currentPage: 1,
  346. total: 0
  347. },
  348. loading: false,
  349. goodsOption: {},
  350. data: [],
  351. goodsList: [],
  352. selectionList: [],
  353. treeDeptId: null,
  354. orderFeesList: [],
  355. freightData: [],
  356. oldform: {},
  357. olddata: [],
  358. oldfreightData: [],
  359. subLoading: false,
  360. pageLoading: false,
  361. showBut: true,
  362. search: {}
  363. };
  364. },
  365. props: {
  366. detailData: {
  367. type: Object
  368. }
  369. },
  370. components: {
  371. reportDialog,
  372. customerDialog
  373. },
  374. async created() {
  375. if (this.detailData.id) {
  376. this.getDetail(this.detailData.id);
  377. }
  378. this.tableOption = await this.getColumnData(
  379. this.getColumnName(13),
  380. tableOption
  381. );
  382. this.goodsOption = await this.getColumnData(
  383. this.getColumnName(32),
  384. goodsOption
  385. );
  386. getPorts().then(res => {
  387. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  388. this.findObject(this.option.column, "portOfDestination").dicData =
  389. res.data;
  390. });
  391. this.getWorkDicts("product_properties").then(res => {
  392. this.findObject(this.tableOption.column, "itemProp").dicData =
  393. res.data.data;
  394. });
  395. },
  396. filters: {
  397. IntegerFormat(num) {
  398. return IntegerFormat(num);
  399. }
  400. },
  401. methods: {
  402. cellStyle() {
  403. return "padding:0;height:40px;";
  404. },
  405. rowCorpData(row) {
  406. this.data[row.index].shippingHouseName = row.cname;
  407. },
  408. rowCell(row, index) {
  409. if (row.$cellEdit == true) {
  410. this.$set(row, "$cellEdit", false);
  411. } else {
  412. this.$set(row, "$cellEdit", true);
  413. }
  414. },
  415. rowDel(row, index) {
  416. this.$confirm("确定删除数据?", {
  417. confirmButtonText: "确定",
  418. cancelButtonText: "取消",
  419. type: "warning"
  420. }).then(() => {
  421. if (row.id) {
  422. delItem(row.id).then(res => {
  423. this.$message({
  424. type: "success",
  425. message: "删除成功!"
  426. });
  427. this.freightData.splice(index, 1);
  428. });
  429. } else {
  430. this.$message({
  431. type: "success",
  432. message: "删除成功!"
  433. });
  434. this.freightData.splice(index, 1);
  435. }
  436. });
  437. },
  438. rowSave(row) {
  439. this.$set(row, "$cellEdit", false);
  440. },
  441. importGoods() {
  442. this.selectionList.forEach(e => {
  443. this.data.push({
  444. itemId: e.id,
  445. code: e.code,
  446. cname: e.cname,
  447. priceCategory: e.goodsTypeName,
  448. itemUrl: e.url,
  449. itemProp: null,
  450. itemDescription: null,
  451. itemType: null,
  452. orderQuantity: 0,
  453. tradeTerms: null,
  454. price: 0,
  455. amount: 0,
  456. taxRate: 0,
  457. unit: e.unit,
  458. remarks: null,
  459. $cellEdit: true
  460. });
  461. });
  462. this.dialogVisible = false;
  463. },
  464. closeGoods() {
  465. this.selectionList = [];
  466. this.treeDeptId = "";
  467. },
  468. selectionChange(list) {
  469. this.selectionList = list;
  470. },
  471. rowClick(row) {
  472. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  473. },
  474. nodeClick(data) {
  475. this.treeDeptId = data.id;
  476. this.page.currentPage = 1;
  477. this.onLoad(this.page);
  478. },
  479. searchChange(params, done) {
  480. this.search = this.deepClone(params);
  481. this.onLoad(this.page, params);
  482. done();
  483. },
  484. //费用查询
  485. onLoad(page, params = {}) {
  486. let obj = this.deepClone(Object.assign(params, this.search));
  487. this.loading = true;
  488. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj).then(
  489. res => {
  490. const data = res.data.data;
  491. this.page.total = data.total;
  492. this.goodsList = data.records;
  493. this.loading = false;
  494. if (this.page.total) {
  495. this.goodsOption.height = window.innerHeight - 350;
  496. }
  497. }
  498. );
  499. },
  500. getDetail(id) {
  501. this.showBut = false;
  502. this.pageLoading = true;
  503. detail(id)
  504. .then(res => {
  505. this.form = res.data.data;
  506. this.data = res.data.data.itemsVOList
  507. ? res.data.data.itemsVOList
  508. : [];
  509. this.freightData = res.data.data.orderFreightList
  510. ? res.data.data.orderFreightList
  511. : [];
  512. this.oldform = res.data.data;
  513. this.olddata = this.deepClone(
  514. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  515. );
  516. this.oldfreightData = this.deepClone(
  517. res.data.data.orderFreightList ? res.data.data.orderFreightList : []
  518. );
  519. })
  520. .finally(() => {
  521. this.showBut = true;
  522. this.pageLoading = false;
  523. });
  524. },
  525. addFreight() {
  526. this.freightData.push({ $cellEdit: true });
  527. },
  528. //修改提交触发
  529. editCustomer(status, status2) {
  530. this.$refs["form"].validate((valid, done) => {
  531. done();
  532. if (valid) {
  533. if (status == "submit") {
  534. this.subLoading = true;
  535. submit({
  536. id: this.form.id,
  537. orderFreightList: this.freightData
  538. })
  539. .then(res => {
  540. this.$message.success("修改成功");
  541. this.form = res.data.data;
  542. this.data = res.data.data.itemsVOList
  543. ? res.data.data.itemsVOList
  544. : [];
  545. this.freightData = res.data.data.orderFreightList
  546. ? res.data.data.orderFreightList
  547. : [];
  548. this.oldform = res.data.data;
  549. this.olddata = this.deepClone(
  550. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  551. );
  552. this.oldfreightData = this.deepClone(
  553. res.data.data.orderFreightList
  554. ? res.data.data.orderFreightList
  555. : []
  556. );
  557. if (status2 == "goBack") {
  558. if (this.form.id) {
  559. this.unLock({
  560. moduleName: "cw",
  561. tableName: "business_order",
  562. billId: this.form.id,
  563. billNo: this.form.orgOrderNo
  564. });
  565. }
  566. this.$emit("goBack");
  567. this.leaveDetailsKey(this.$route.name);
  568. }
  569. })
  570. .finally(() => {
  571. this.subLoading = false;
  572. });
  573. }
  574. if (status == "fix") {
  575. commit({
  576. id: this.form.id,
  577. orderFreightList: this.freightData
  578. }).then(res => {
  579. this.$message.success("提交成功");
  580. this.form = res.data.data;
  581. this.data = res.data.data.orderItemsList
  582. ? res.data.data.orderItemsList
  583. : [];
  584. this.freightData = res.data.data.orderFreightList
  585. ? res.data.data.orderFreightList
  586. : [];
  587. this.oldform = res.data.data;
  588. this.olddata = this.deepClone(
  589. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  590. );
  591. this.oldfreightData = this.deepClone(
  592. res.data.data.orderFreightList
  593. ? res.data.data.orderFreightList
  594. : []
  595. );
  596. });
  597. }
  598. } else {
  599. return false;
  600. }
  601. });
  602. },
  603. //返回列表
  604. backToList() {
  605. if (
  606. contrastObj(this.form, this.oldform) ||
  607. contrastList(this.data, this.olddata) ||
  608. contrastList(this.freightData, this.oldfreightData)
  609. ) {
  610. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  611. confirmButtonText: "确定",
  612. cancelButtonText: "取消",
  613. type: "warning"
  614. })
  615. .then(() => {
  616. this.editCustomer("submit", "goBack");
  617. })
  618. .catch(() => {
  619. if (this.form.id) {
  620. this.unLock({
  621. moduleName: "cw",
  622. tableName: "business_order",
  623. billId: this.form.id,
  624. billNo: this.form.orgOrderNo
  625. });
  626. }
  627. this.$emit("goBack");
  628. this.leaveDetailsKey(this.$route.name);
  629. });
  630. } else {
  631. if (this.form.id) {
  632. this.unLock({
  633. moduleName: "cw",
  634. tableName: "business_order",
  635. billId: this.form.id,
  636. billNo: this.form.orgOrderNo
  637. });
  638. }
  639. this.$emit("goBack");
  640. this.leaveDetailsKey(this.$route.name);
  641. }
  642. },
  643. onClose(val) {
  644. this.switchDialog = val;
  645. },
  646. summaryMethod({ columns, data }) {
  647. const sums = [];
  648. if (columns.length > 0) {
  649. columns.forEach((item, index) => {
  650. sums[0] = "合计";
  651. if (item.property == "orderQuantity" || item.property == "amount") {
  652. let qtySum = 0;
  653. let amountSum = 0;
  654. data.forEach(e => {
  655. qtySum = _.add(qtySum, Number(e.orderQuantity));
  656. amountSum = _.add(amountSum, Number(e.amount));
  657. });
  658. //数量总计
  659. if (item.property == "orderQuantity") {
  660. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  661. }
  662. //金额总计
  663. if (item.property == "amount") {
  664. sums[index] = micrometerFormat(amountSum);
  665. }
  666. }
  667. });
  668. }
  669. return sums;
  670. },
  671. openEdit() {
  672. const data = {
  673. moduleName: "cw",
  674. tableName: "business_order",
  675. billId: this.form.id,
  676. no: localStorage.getItem("browserID"),
  677. billNo: this.form.orgOrderNo
  678. };
  679. this.inDetailsKey(this.$route.name, {
  680. moduleName: "cw",
  681. tableName: "business_order",
  682. billId: this.form.id,
  683. billNo: this.form.orgOrderNo
  684. });
  685. this.checkLock(data).then(res => {
  686. if (res.data.code == 200) {
  687. this.onLock(data).then(res => {
  688. if (res.data.code == 200) {
  689. this.detailData.status = 2;
  690. this.option = this.$options.data().option;
  691. }
  692. });
  693. }
  694. });
  695. },
  696. async saveColumn() {
  697. const inSave = await this.saveColumnData(
  698. this.getColumnName(13),
  699. this.tableOption
  700. );
  701. if (inSave) {
  702. this.$message.success("保存成功");
  703. //关闭窗口
  704. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  705. }
  706. },
  707. async resetColumn() {
  708. this.tableOption = tableOption;
  709. const inSave = await this.delColumnData(
  710. this.getColumnName(13),
  711. tableOption
  712. );
  713. if (inSave) {
  714. this.$message.success("重置成功");
  715. //关闭窗口
  716. setTimeout(() => {
  717. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  718. }, 1000);
  719. }
  720. },
  721. async saveGoodsColumn() {
  722. const inSave = await this.saveColumnData(
  723. this.getColumnName(32),
  724. this.goodsOption
  725. );
  726. if (inSave) {
  727. this.$message.success("保存成功");
  728. //关闭窗口
  729. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  730. }
  731. },
  732. async resetGoodsColumn() {
  733. this.goodsOption = goodsOption;
  734. const inSave = await this.delColumnData(
  735. this.getColumnName(32),
  736. goodsOption
  737. );
  738. if (inSave) {
  739. this.$message.success("重置成功");
  740. //关闭窗口
  741. setTimeout(() => {
  742. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  743. }, 1000);
  744. }
  745. }
  746. }
  747. };
  748. </script>
  749. <style lang="scss" scoped>
  750. .trading-form ::v-deep .el-form-item {
  751. margin-bottom: 8px !important;
  752. }
  753. ::v-deep .el-form-item__error {
  754. display: none !important;
  755. }
  756. ::v-deep .select-component {
  757. display: flex !important;
  758. }
  759. </style>