detailsPage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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. <el-button
  15. class="el-button--small-yh add-customer-btn"
  16. type="primary"
  17. :disabled="disabled"
  18. @click="editCustomer"
  19. >提 交
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 60px;margin-bottom:35px">
  23. <containerTitle title="基础信息"></containerTitle>
  24. <basic-container style="margin-bottom: 10px">
  25. <avue-form ref="form" v-model="form" :option="option">
  26. <template slot="corpId">
  27. <select-component
  28. v-model="form.corpId"
  29. :configuration="configuration"
  30. :disabled="true"
  31. ></select-component>
  32. </template>
  33. <template slot="exchangeRate">
  34. <el-input
  35. size="mini"
  36. v-model="form.exchangeRate"
  37. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  38. @change="rateChange"
  39. placeholder="请输入 汇率"
  40. disabled
  41. ><template slot="append">%</template></el-input
  42. >
  43. </template>
  44. </avue-form>
  45. </basic-container>
  46. <containerTitle title="商品信息"></containerTitle>
  47. <basic-container>
  48. <avue-crud
  49. :ref="crud"
  50. :data="data"
  51. :option="tableOption"
  52. @row-del="rowDel"
  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. <fee-info
  66. ref="feeInfo"
  67. :orderFeesList="orderFeesList"
  68. feeUrl="/trade-purchase/shipping-enquiry/removeByFees"
  69. />
  70. </div>
  71. <el-dialog
  72. title="导入商品"
  73. append-to-body
  74. class="el-dialogDeep"
  75. :visible.sync="dialogVisible"
  76. width="60%"
  77. :close-on-click-modal="false"
  78. :destroy-on-close="true"
  79. :close-on-press-escape="false"
  80. @close="closeGoods"
  81. top="10vh"
  82. >
  83. <span>
  84. <el-row>
  85. <el-col :span="5">
  86. <div>
  87. <el-scrollbar>
  88. <basic-container style="margin-top:45px">
  89. <avue-tree :option="treeOption" @node-click="nodeClick" />
  90. </basic-container>
  91. </el-scrollbar>
  92. </div>
  93. </el-col>
  94. <el-col :span="19">
  95. <avue-crud
  96. :option="goodsOption"
  97. :table-loading="loading"
  98. :data="goodsList"
  99. ref="goodsCrud"
  100. @refresh-change="refreshChange"
  101. @selection-change="selectionChange"
  102. @row-click="rowClick"
  103. :page.sync="page"
  104. @on-load="onLoad"
  105. ></avue-crud>
  106. </el-col>
  107. </el-row>
  108. </span>
  109. <span slot="footer" class="dialog-footer">
  110. <el-button @click="dialogVisible = false">取 消</el-button>
  111. <el-button
  112. type="primary"
  113. @click="importGoods"
  114. :disabled="selectionList.length == 0"
  115. >导入</el-button
  116. >
  117. </span>
  118. </el-dialog>
  119. <report-dialog
  120. :switchDialog="switchDialog"
  121. :reportId="form.id"
  122. reportName="客户询价"
  123. @onClose="onClose()"
  124. ></report-dialog>
  125. </div>
  126. </template>
  127. <script>
  128. import tableOption from "./config/customerContact.json";
  129. import goodsOption from "./config/commodity.json";
  130. import feeInfo from "@/components/fee-info/main";
  131. import {
  132. detail,
  133. submit,
  134. getDeptLazyTree,
  135. getGoods,
  136. getPorts
  137. } from "@/api/basicData/shippingInquiry";
  138. import reportDialog from "@/components/report-dialog/main";
  139. import { isvalidatemobile, validatename } from "@/util/validate";
  140. export default {
  141. name: "detailsPageEdit",
  142. data() {
  143. const validatePhone = (rule, value, callback) => {
  144. if (value != "") {
  145. if (isvalidatemobile(value)[0]) {
  146. this.$message.error("手机号码格式不正确");
  147. callback(new Error(isvalidatemobile(value)[1]));
  148. } else {
  149. callback();
  150. }
  151. } else {
  152. callback();
  153. }
  154. };
  155. const validateName = (rule, value, callback) => {
  156. if (value != "") {
  157. if (validatename(value)) {
  158. this.$message.error("联系人格式不正确");
  159. callback(new Error(validatename(value)));
  160. } else {
  161. callback();
  162. }
  163. } else {
  164. callback();
  165. }
  166. };
  167. return {
  168. configuration: {
  169. multipleChoices: false,
  170. multiple: false,
  171. collapseTags: false,
  172. placeholder: "请点击右边按钮选择",
  173. dicData: []
  174. },
  175. switchDialog: false,
  176. form: {},
  177. disabled: false,
  178. dialogVisible: false,
  179. tableOption: tableOption,
  180. option: {
  181. menuBtn: false,
  182. labelWidth: 100,
  183. disabled: true,
  184. column: [
  185. {
  186. label: "客户名称",
  187. prop: "corpId",
  188. rules: [
  189. {
  190. required: true,
  191. message: "",
  192. trigger: "blur"
  193. }
  194. ],
  195. span: 8,
  196. slot: true
  197. },
  198. {
  199. label: "系统号",
  200. prop: "sysNo",
  201. span: 8
  202. },
  203. {
  204. label: "订单状态",
  205. prop: "orderStatus",
  206. span: 8,
  207. type: "select",
  208. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  209. props: {
  210. label: "dictValue",
  211. value: "dictValue"
  212. }
  213. },
  214. {
  215. label: "联系人",
  216. prop: "corpAttn",
  217. span: 8,
  218. rules: [{ validator: validateName, trigger: "blur" }]
  219. },
  220. {
  221. label: "电话",
  222. prop: "corpTel",
  223. span: 8,
  224. rules: [{ validator: validatePhone, trigger: "blur" }]
  225. },
  226. {
  227. label: "起运港",
  228. prop: "portOfLoad",
  229. span: 8,
  230. type: "select",
  231. filterable: true,
  232. dicData: [],
  233. props: {
  234. label: "name",
  235. value: "name"
  236. }
  237. },
  238. {
  239. label: "目的港",
  240. prop: "portOfDestination",
  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: "transport",
  253. span: 8,
  254. type: "select",
  255. dicUrl: "/api/blade-system/dict-biz/dictionary?code=mode_transport",
  256. props: {
  257. label: "dictValue",
  258. value: "dictValue"
  259. }
  260. },
  261. {
  262. label: "价格条款",
  263. prop: "priceTerms",
  264. span: 8,
  265. type: "select",
  266. dicUrl: "/api/blade-system/dict-biz/dictionary?code=pricing_terms",
  267. props: {
  268. label: "dictValue",
  269. value: "dictValue"
  270. }
  271. },
  272. {
  273. label: "条款说明",
  274. prop: "priceTermsDescription",
  275. span: 8
  276. },
  277. {
  278. label: "订单日期",
  279. prop: "businesDate",
  280. span: 8,
  281. type: "date",
  282. format: "yyyy-MM-dd",
  283. valueFormat: "yyyy-MM-dd 00:00:00"
  284. },
  285. {
  286. label: "有效日期",
  287. prop: "dateValidity",
  288. span: 8,
  289. type: "date",
  290. format: "yyyy-MM-dd",
  291. valueFormat: "yyyy-MM-dd 00:00:00"
  292. },
  293. {
  294. label: "收款方式",
  295. prop: "paymentType",
  296. span: 8,
  297. type: "select",
  298. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  299. props: {
  300. label: "dictValue",
  301. value: "dictValue"
  302. }
  303. },
  304. {
  305. label: "收款说明",
  306. prop: "paymentTypeDescription",
  307. span: 8
  308. },
  309. {
  310. label: "币别",
  311. prop: "currency",
  312. span: 8,
  313. type: "select",
  314. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  315. props: {
  316. label: "dictValue",
  317. value: "dictValue"
  318. }
  319. },
  320. {
  321. label: "汇率",
  322. prop: "exchangeRate",
  323. span: 8,
  324. slot: true
  325. },
  326. {
  327. label: "备注",
  328. prop: "orderRemark",
  329. type: "textarea",
  330. minRows: 2,
  331. span: 16
  332. }
  333. ]
  334. },
  335. treeOption: {
  336. nodeKey: "id",
  337. lazy: true,
  338. treeLoad: function(node, resolve) {
  339. const parentId = node.level === 0 ? 0 : node.data.id;
  340. getDeptLazyTree(parentId).then(res => {
  341. resolve(
  342. res.data.data.map(item => {
  343. return {
  344. ...item,
  345. leaf: !item.hasChildren
  346. };
  347. })
  348. );
  349. });
  350. },
  351. addBtn: false,
  352. menu: false,
  353. size: "small",
  354. props: {
  355. label: "title",
  356. value: "value",
  357. children: "children"
  358. }
  359. },
  360. page: {
  361. pageSize: 10,
  362. currentPage: 1,
  363. total: 0
  364. },
  365. loading: false,
  366. goodsOption: goodsOption,
  367. data: [],
  368. goodsList: [],
  369. selectionList: [],
  370. treeDeptId: null,
  371. orderFeesList: []
  372. };
  373. },
  374. props: {
  375. detailData: {
  376. type: Object
  377. }
  378. },
  379. components: {
  380. reportDialog,
  381. feeInfo
  382. },
  383. created() {
  384. if (this.detailData.id) {
  385. this.getDetail(this.detailData.id);
  386. }
  387. let _this = this;
  388. this.tableOption.column.forEach(e => {
  389. if (e.prop == "taxRate") {
  390. e.formatter = function(row) {
  391. return _this.textFormat(
  392. Number(row.taxRate ? row.taxRate : 0) / 100,
  393. "0.00%"
  394. );
  395. };
  396. }
  397. if (e.prop == "amount" || e.prop == "price") {
  398. e.formatter = function(row) {
  399. return _this.textFormat(
  400. Number(row.amount ? row.amount : 0),
  401. "#,##0.00"
  402. );
  403. };
  404. }
  405. });
  406. getPorts().then(res => {
  407. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  408. this.findObject(this.option.column, "portOfDestination").dicData =
  409. res.data;
  410. });
  411. },
  412. methods: {
  413. rateChange(row) {
  414. if (row >= 100) {
  415. this.form.exchangeRate = 0;
  416. this.$message.error("汇率不能超过100%");
  417. }
  418. },
  419. rowSave(row) {
  420. this.$set(row, "$cellEdit", false);
  421. },
  422. importGoods() {
  423. this.selectionList.forEach(e => {
  424. this.data.push({
  425. itemId: e.id,
  426. code: e.code,
  427. cname: e.cname,
  428. priceCategory: e.goodsTypeName,
  429. itemUrl: e.url,
  430. itemProp: null,
  431. itemDescription: null,
  432. itemType: null,
  433. orderQuantity: 0,
  434. tradeTerms: null,
  435. price: 0,
  436. amount: 0,
  437. taxRate: 0,
  438. unit: e.unit,
  439. remarks: null,
  440. $cellEdit: true
  441. });
  442. });
  443. this.dialogVisible = false;
  444. },
  445. closeGoods() {
  446. this.selectionList = [];
  447. this.treeDeptId = "";
  448. },
  449. selectionChange(list) {
  450. this.selectionList = list;
  451. },
  452. rowClick(row) {
  453. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  454. },
  455. nodeClick(data) {
  456. this.treeDeptId = data.id;
  457. this.page.currentPage = 1;
  458. this.onLoad(this.page);
  459. },
  460. //费用查询
  461. onLoad(page, params = {}) {
  462. this.loading = true;
  463. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  464. const data = res.data.data;
  465. this.page.total = data.total;
  466. this.goodsList = data.records;
  467. this.loading = false;
  468. if (this.page.total) {
  469. this.goodsOption.height = window.innerHeight - 550;
  470. } else {
  471. this.goodsOption.height = window.innerHeight - 475;
  472. }
  473. });
  474. },
  475. getDetail(id) {
  476. detail(id).then(res => {
  477. this.form = res.data.data;
  478. this.data = res.data.data.itemsVOList;
  479. this.orderFeesList = res.data.data.orderFeesList;
  480. this.configuration.dicData = this.form.corpsName;
  481. });
  482. },
  483. //修改提交触发
  484. editCustomer() {
  485. this.$refs["form"].validate((valid, done) => {
  486. done();
  487. if (valid) {
  488. let orderFeesList = this.$refs.feeInfo.submitData();
  489. for (let i = 0; i < orderFeesList.length; i++) {
  490. if (orderFeesList[i].corpId == null) {
  491. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  492. }
  493. if (orderFeesList[i].price == 0) {
  494. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  495. }
  496. if (orderFeesList[i].quantity == 0) {
  497. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  498. }
  499. }
  500. submit({
  501. id: this.form.id,
  502. orderFeesList: orderFeesList
  503. }).then(res => {
  504. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  505. });
  506. } else {
  507. return false;
  508. }
  509. });
  510. },
  511. //返回列表
  512. backToList() {
  513. this.$emit("goBack");
  514. },
  515. onClose(val) {
  516. this.switchDialog = val;
  517. }
  518. }
  519. };
  520. </script>
  521. <style lang="scss" scoped>
  522. .customer-head {
  523. position: fixed;
  524. top: 105px;
  525. width: 100%;
  526. margin-left: -10px;
  527. height: 62px;
  528. background: #ffffff;
  529. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  530. z-index: 999;
  531. }
  532. .customer-back {
  533. cursor: pointer;
  534. line-height: 62px;
  535. font-size: 16px;
  536. color: #323233;
  537. font-weight: 400;
  538. }
  539. .back-icon {
  540. line-height: 64px;
  541. font-size: 20px;
  542. margin-right: 8px;
  543. }
  544. .copy-customer-btn {
  545. position: fixed;
  546. right: 140px;
  547. top: 115px;
  548. }
  549. .add-customer-btn {
  550. position: fixed;
  551. right: 36px;
  552. top: 115px;
  553. }
  554. ::v-deep .el-form-item {
  555. margin-bottom: 8px;
  556. }
  557. ::v-deep .el-form-item__error {
  558. display: none;
  559. }
  560. ::v-deep .select-component {
  561. display: flex;
  562. }
  563. </style>