detailsPage.vue 18 KB

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