detailsPage.vue 18 KB

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