detailsPage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button type="primary" size="small" @click="editCustomer">
  12. 保存数据
  13. </el-button>
  14. </div>
  15. </div>
  16. <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle>
  17. <basic-container v-loading="loadingBtn">
  18. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  19. <template slot="outHarborName">
  20. <port-info v-model="form.outHarborName" />
  21. </template>
  22. <template slot="objectiveName">
  23. <port-info v-model="form.objectiveName" />
  24. </template>
  25. </avue-form>
  26. </basic-container>
  27. <containerTitle title="基础明细"></containerTitle>
  28. <basic-container v-loading="loadingBtn">
  29. <el-tabs>
  30. <el-tab-pane label="运费">
  31. <avue-crud ref="crud" :option="optionList" :data="dataList" :table-loading="loading"
  32. @saveColumn="saveColumn" @resetColumn="resetColumn" :cell-style="cellStyle" @row-save="rowSave"
  33. @row-update="addUpdate">
  34. <template slot="menuLeft">
  35. <el-button type="primary" @click="addRow" size="small">新增
  36. </el-button>
  37. </template>
  38. <template slot="feesId" slot-scope="{ row,index }">
  39. <breakdown-select v-if="row.$cellEdit" v-model="row.feesId"
  40. @selectValue="value => selectValue(value,row)" :configuration="breakConfiguration">
  41. </breakdown-select>
  42. <span v-else>{{ row.feesName }}</span>
  43. </template>
  44. <template slot="currency" slot-scope="{ row,index }">
  45. <el-select size="small" v-if="row.$cellEdit" v-model="row.currency" placeholder="请选择" clearable>
  46. <el-option v-for="item in currencyList" :key="item.id" :label="item" :value="item">
  47. </el-option>
  48. </el-select>
  49. <span v-else>{{ row.currency}}</span>
  50. </template>
  51. <template slot="menu" slot-scope="{ row, index }">
  52. <el-button size="small" type="text" @click="rowCell(row, index)">{{
  53. row.$cellEdit ? "保存" : "修改" }}</el-button>
  54. <el-button size="small" type="text" @click="rowDel(row, index)">删除
  55. </el-button>
  56. </template>
  57. </avue-crud>
  58. </el-tab-pane>
  59. <el-tab-pane label="杂费">
  60. <avue-crud ref="crud2" :option="optionList2" :data="dataList2" :table-loading="loading"
  61. @saveColumn="saveColumn2" @resetColumn="resetColumn2" :cell-style="cellStyle" @row-save="rowSave2"
  62. @row-update="addUpdate2">
  63. <template slot="menuLeft">
  64. <el-button type="primary" @click="addRow2" size="small" :disabled="detailData.status == 1">新增
  65. </el-button>
  66. </template>
  67. <template slot="feesId" slot-scope="{ row,index }">
  68. <breakdown-select v-if="row.$cellEdit" v-model="row.feesId"
  69. @selectValue="value => selectValue(value,row)" :configuration="breakConfiguration">
  70. </breakdown-select>
  71. <span v-else>{{ row.feesName }}</span>
  72. </template>
  73. <template slot="currency" slot-scope="{ row,index }">
  74. <el-select size="small" v-if="row.$cellEdit" v-model="row.currency" placeholder="请选择" clearable>
  75. <el-option v-for="item in currencyList" :key="item.id" :label="item" :value="item">
  76. </el-option>
  77. </el-select>
  78. <span v-else>{{ row.currency}}</span>
  79. </template>
  80. <template slot="menu" slot-scope="{ row, index }">
  81. <el-button size="small" type="text" @click="rowCell2(row, index)">{{
  82. row.$cellEdit ? "保存" : "修改" }}</el-button>
  83. <el-button size="small" type="text" @click="rowDel2(row, index)">删除
  84. </el-button>
  85. </template>
  86. </avue-crud>
  87. </el-tab-pane>
  88. </el-tabs>
  89. </basic-container>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import { optionList, optionList2 } from "./js/optionList";
  95. import { getDetail, submit, itemDel } from "@/api/maintenance/landFreight";
  96. import { areaTypeTree } from "@/api/basicData/customerInformation";
  97. import { getCode } from "@/api/basicData/customerInquiry";
  98. export default {
  99. name: "index",
  100. data() {
  101. return {
  102. loadingBtn: false,
  103. form: {},
  104. dataList: [],
  105. dataList2: [],
  106. option: {
  107. menuBtn: false,
  108. labelWidth: 130,
  109. column: [
  110. {
  111. label: "货物属性",
  112. prop: "goodsAttribute",
  113. type: "select",
  114. dicUrl: "/api/blade-system/dict-biz/dictionary?code=cargo_type",
  115. props: {
  116. label: "dictValue",
  117. value: "dictValue"
  118. },
  119. rules: [
  120. {
  121. required: true,
  122. message: "",
  123. trigger: "blur"
  124. }
  125. ],
  126. span: 8,
  127. },
  128. {
  129. label: "起运港",
  130. prop: "outHarborName",
  131. span: 8,
  132. },
  133. {
  134. label: "目的港",
  135. prop: "objectiveName",
  136. span: 8,
  137. },
  138. {
  139. label: "备注",
  140. prop: "remarks",
  141. type: "textarea",
  142. minRows: 2,
  143. span: 24,
  144. }
  145. ]
  146. },
  147. optionList: {},
  148. optionList2: {},
  149. breakConfiguration: {
  150. multipleChoices: false,
  151. multiple: false,
  152. disabled: false,
  153. searchShow: true,
  154. collapseTags: false,
  155. clearable: true,
  156. placeholder: "请点击右边按钮选择",
  157. dicData: []
  158. },
  159. currencyList: []
  160. };
  161. },
  162. props: {
  163. detailData: {
  164. type: Object
  165. }
  166. },
  167. async created() {
  168. this.optionList = await this.getColumnData(
  169. this.getColumnName(206),
  170. optionList
  171. );
  172. this.optionList2 = await this.getColumnData(
  173. this.getColumnName(206.1),
  174. optionList2
  175. );
  176. if (this.detailData.id) {
  177. this.getDetail(this.detailData.id);
  178. }
  179. if (this.detailData.status == 1) {
  180. this.option.disabled = true;
  181. }
  182. getCode().then(res => {
  183. this.currencyList = res.data.data;
  184. });
  185. },
  186. methods: {
  187. cellStyle() {
  188. return "padding:0;height:40px;";
  189. },
  190. selectValue(value, row) {
  191. console.log(value, row)
  192. if (row.feesId) {
  193. row.feesName = value.cname
  194. } else {
  195. row.feesName = ""
  196. }
  197. },
  198. getDetail(id) {
  199. this.loadingBtn = true
  200. getDetail(id)
  201. .then(res => {
  202. this.form = res.data.data;
  203. this.dataList = res.data.data.orderCostItemList.filter(e => e.type == 2);
  204. this.dataList2 = res.data.data.orderCostItemList.filter(e => e.type == 3);
  205. })
  206. .finally(() => {
  207. this.loadingBtn = false;
  208. });
  209. },
  210. getCorpData(row) {
  211. this.form.corpName = row.cname
  212. },
  213. addRow() {
  214. this.dataList.push({ currency: 'CNY', type: 2, $cellEdit: true });
  215. },
  216. rowCell(row, index) {
  217. this.$refs.crud.rowCell(row, index)
  218. },
  219. rowSave(form, done) {
  220. done()
  221. },
  222. addUpdate(form, index, done, loading) {
  223. done()
  224. },
  225. rowDel(row, index) {
  226. this.$confirm("确定删除数据?", {
  227. confirmButtonText: "确定",
  228. cancelButtonText: "取消",
  229. type: "warning"
  230. }).then(() => {
  231. if (row.id) {
  232. itemDel(row.id).then(res => {
  233. this.$message({
  234. type: "success",
  235. message: "删除成功!"
  236. });
  237. this.dataList.splice(index, 1);
  238. });
  239. } else {
  240. this.$message({
  241. type: "success",
  242. message: "删除成功!"
  243. });
  244. this.dataList.splice(index, 1);
  245. }
  246. });
  247. },
  248. addRow2() {
  249. this.dataList2.push({ currency: 'CNY', type: 3, $cellEdit: true });
  250. },
  251. rowCell2(row, index) {
  252. this.$refs.crud2.rowCell(row, index)
  253. },
  254. rowSave2(form, done) {
  255. done()
  256. },
  257. addUpdate2(form, index, done, loading) {
  258. done()
  259. },
  260. rowDel2(row, index) {
  261. this.$confirm("确定删除数据?", {
  262. confirmButtonText: "确定",
  263. cancelButtonText: "取消",
  264. type: "warning"
  265. }).then(() => {
  266. if (row.id) {
  267. itemDel(row.id).then(res => {
  268. this.$message({
  269. type: "success",
  270. message: "删除成功!"
  271. });
  272. this.dataList2.splice(index, 1);
  273. });
  274. } else {
  275. this.$message({
  276. type: "success",
  277. message: "删除成功!"
  278. });
  279. this.dataList2.splice(index, 1);
  280. }
  281. });
  282. },
  283. //修改提交触发
  284. editCustomer() {
  285. this.$refs["form"].validate((valid, done) => {
  286. done();
  287. if (valid) {
  288. this.loadingBtn = true;
  289. submit({ ...this.form, feesType: 2, orderCostItemList: this.dataList.concat(this.dataList2) })
  290. .then(res => {
  291. this.$message.success("保存成功");
  292. this.form = res.data.data;
  293. this.dataList = res.data.data.orderCostItemList.filter(e => e.type == 2);
  294. this.dataList2 = res.data.data.orderCostItemList.filter(e => e.type == 3);
  295. })
  296. .finally(() => {
  297. this.loadingBtn = false;
  298. });
  299. } else {
  300. return false;
  301. }
  302. });
  303. },
  304. async saveColumn() {
  305. const inSave = await this.saveColumnData(
  306. this.getColumnName(206),
  307. this.optionList
  308. );
  309. if (inSave) {
  310. this.$nextTick(() => {
  311. this.$refs.crud.doLayout();
  312. });
  313. this.$message.success("保存成功");
  314. //关闭窗口
  315. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  316. }
  317. },
  318. async resetColumn() {
  319. this.optionList = optionList;
  320. const inSave = await this.delColumnData(
  321. this.getColumnName(206),
  322. optionList
  323. );
  324. if (inSave) {
  325. this.$nextTick(() => {
  326. this.$refs.crud.doLayout();
  327. });
  328. this.$message.success("重置成功");
  329. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  330. }
  331. },
  332. async saveColumn2() {
  333. const inSave = await this.saveColumnData(
  334. this.getColumnName(206.1),
  335. this.optionList2
  336. );
  337. if (inSave) {
  338. this.$nextTick(() => {
  339. this.$refs.crud.doLayout();
  340. });
  341. this.$message.success("保存成功");
  342. //关闭窗口
  343. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  344. }
  345. },
  346. async resetColumn2() {
  347. this.optionList2 = optionList2;
  348. const inSave = await this.delColumnData(
  349. this.getColumnName(206.1),
  350. optionList2
  351. );
  352. if (inSave) {
  353. this.$nextTick(() => {
  354. this.$refs.crud.doLayout();
  355. });
  356. this.$message.success("重置成功");
  357. this.$refs.crud2.$refs.dialogColumn.columnBox = false;
  358. }
  359. },
  360. //返回列表
  361. backToList() {
  362. this.$emit("goBack");
  363. }
  364. }
  365. };
  366. </script>
  367. <style lang="scss" scoped>
  368. .trading-form ::v-deep .el-form-item {
  369. margin-bottom: 8px !important;
  370. }
  371. ::v-deep .el-form-item__error {
  372. display: none !important;
  373. }
  374. .img-form ::v-deep .el-form-item {
  375. height: 150px;
  376. line-height: 150px;
  377. margin-bottom: 8px !important;
  378. }
  379. .img-form ::v-deep .avue-upload__icon {
  380. font-size: 20px;
  381. width: 150px;
  382. height: 150px;
  383. line-height: 150px;
  384. }
  385. ::v-deep .el-table .cell {
  386. padding: 0 2px !important;
  387. }
  388. ::v-deep .avue-crud .el-table .el-form-item__label {
  389. left: -1px;
  390. }
  391. </style>