detailsPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  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" v-if="showBut">
  15. <el-button
  16. type="primary"
  17. :disabled="disabled"
  18. @click="editCustomer"
  19. size="small"
  20. :loading="subLoading"
  21. v-if="detailData.status != 1"
  22. >{{ form.id ? "确认修改" : "确认新增" }}
  23. </el-button>
  24. </div>
  25. </div>
  26. <div style="margin-top: 60px;margin-bottom:35px">
  27. <containerTitle title="基础信息"></containerTitle>
  28. <basic-container style="margin-bottom: 10px">
  29. <avue-form ref="form" v-model="form" :option="option">
  30. <template slot="corpId">
  31. <select-component
  32. v-model="form.corpId"
  33. :configuration="configuration"
  34. :disabled="detailData.status == 1"
  35. ></select-component>
  36. </template>
  37. <template slot="cname">
  38. <goods-select
  39. v-model="form.cname"
  40. :configuration="goodsConfiguration"
  41. @getRow="getGoodsRow"
  42. @returnRow="returnRow"
  43. :disabled="detailData.status == 1"
  44. />
  45. </template>
  46. </avue-form>
  47. </basic-container>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { detail, submit } from "@/api/maintenance/priceLibrary";
  53. import { contrastObj } from "@/util/contrastData";
  54. import { orderStates } from "@/enums/order-stauts";
  55. import _ from "lodash";
  56. export default {
  57. name: "detailsPageEdit",
  58. data() {
  59. return {
  60. goodsConfiguration: {
  61. multipleChoices: false,
  62. multiple: false,
  63. collapseTags: false,
  64. placeholder: "请点击右边按钮选择",
  65. dicData: [],
  66. clearable: true
  67. },
  68. configuration: {
  69. multipleChoices: false,
  70. multiple: false,
  71. collapseTags: false,
  72. placeholder: "请点击右边按钮选择",
  73. dicData: []
  74. },
  75. form: {},
  76. option: {
  77. menuBtn: false,
  78. labelWidth: 100,
  79. column: [
  80. {
  81. label: "商品名称",
  82. prop: "cname",
  83. rules: [
  84. {
  85. required: true,
  86. message: "",
  87. trigger: "blur"
  88. }
  89. ],
  90. span: 8
  91. },
  92. {
  93. label: "规格",
  94. prop: "specs",
  95. disabled: true,
  96. span: 8
  97. },
  98. {
  99. label: "产品属性",
  100. prop: "goodNature",
  101. span: 8
  102. },
  103. {
  104. label: "供应商",
  105. prop: "corpId",
  106. rules: [
  107. {
  108. required: true,
  109. message: "",
  110. trigger: "blur"
  111. }
  112. ],
  113. span: 8
  114. },
  115. {
  116. label: "币别",
  117. prop: "currency",
  118. type: "select",
  119. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  120. props: {
  121. label: "dictValue",
  122. value: "dictValue"
  123. },
  124. rules: [
  125. {
  126. required: true,
  127. message: "",
  128. trigger: "blur"
  129. }
  130. ],
  131. change: ({ value }) => {
  132. if (value == "CNY") {
  133. this.form.exchangeRate = 1;
  134. }
  135. if (value == "USD") {
  136. this.form.exchangeRate = 6.3843;
  137. }
  138. },
  139. span: 8
  140. },
  141. {
  142. label: "汇率",
  143. prop: "exchangeRate",
  144. disabled: true,
  145. span: 8
  146. },
  147. {
  148. label: "FOB系数",
  149. prop: "coefficient",
  150. rules: [
  151. {
  152. required: true,
  153. message: "",
  154. trigger: "blur"
  155. }
  156. ],
  157. span: 8
  158. },
  159. {
  160. label: "价格类型",
  161. prop: "billType",
  162. rules: [
  163. {
  164. required: true,
  165. message: "",
  166. trigger: "blur"
  167. }
  168. ],
  169. type: "select",
  170. dicUrl: "/api/blade-system/dict-biz/dictionary?code=billType",
  171. props: {
  172. label: "dictValue",
  173. value: "dictKey"
  174. },
  175. span: 8
  176. },
  177. {
  178. label: "最新价格",
  179. prop: "price",
  180. rules: [
  181. {
  182. required: true,
  183. message: "",
  184. trigger: "blur"
  185. }
  186. ],
  187. span: 8
  188. },
  189. {
  190. label: "美元价格",
  191. prop: "greenback",
  192. span: 8
  193. },
  194. {
  195. label: "采购价格",
  196. prop: "purchaseAmount",
  197. span: 8
  198. },
  199. {
  200. label: "税率",
  201. prop: "taxRate",
  202. span: 8
  203. },
  204. {
  205. label: "商品类别",
  206. prop: "goodsTypeName",
  207. span: 8
  208. },
  209. {
  210. label: "状态",
  211. prop: "status",
  212. type: "select",
  213. dicData: orderStates,
  214. props: {
  215. label: "name",
  216. value: "code"
  217. },
  218. rules: [
  219. {
  220. required: true,
  221. message: "",
  222. trigger: "blur"
  223. }
  224. ],
  225. span: 8
  226. },
  227. {
  228. label: "有效期开始",
  229. prop: "startTime",
  230. type: "date",
  231. format: "yyyy-MM-dd",
  232. valueFormat: "yyyy-MM-dd 00:00:00",
  233. rules: [
  234. {
  235. required: true,
  236. message: "",
  237. trigger: "blur"
  238. }
  239. ],
  240. span: 8
  241. },
  242. {
  243. label: "有效期结束",
  244. prop: "endTime",
  245. type: "date",
  246. format: "yyyy-MM-dd",
  247. valueFormat: "yyyy-MM-dd 23:59:59",
  248. rules: [
  249. {
  250. required: true,
  251. message: "",
  252. trigger: "blur"
  253. }
  254. ],
  255. span: 8
  256. },
  257. {
  258. label: "业务员",
  259. prop: "person",
  260. span: 8,
  261. row: true
  262. },
  263. {
  264. label: "历史价格1",
  265. prop: "priceOne",
  266. span: 8,
  267. disabled: true
  268. },
  269. {
  270. label: "历史日期1",
  271. prop: "priceOneTime",
  272. type: "datetime",
  273. format: "yyyy-MM-dd hh:mm:ss",
  274. valueFormat: "yyyy-MM-dd hh:mm:ss",
  275. span: 8,
  276. disabled: true
  277. },
  278. {
  279. label: "历史价格2",
  280. prop: "priceTwo",
  281. span: 8,
  282. disabled: true
  283. },
  284. {
  285. label: "历史日期2",
  286. prop: "priceTwoTime",
  287. type: "datetime",
  288. format: "yyyy-MM-dd hh:mm:ss",
  289. valueFormat: "yyyy-MM-dd hh:mm:ss",
  290. span: 8,
  291. disabled: true
  292. },
  293. {
  294. label: "历史价格3",
  295. prop: "priceThree",
  296. span: 8,
  297. disabled: true
  298. },
  299. {
  300. label: "历史日期3",
  301. prop: "priceThreeTime",
  302. type: "datetime",
  303. format: "yyyy-MM-dd hh:mm:ss",
  304. valueFormat: "yyyy-MM-dd hh:mm:ss",
  305. span: 8,
  306. disabled: true
  307. },
  308. {
  309. label: "备注",
  310. prop: "remarks",
  311. type: "textarea",
  312. minRows: 2,
  313. span: 24
  314. }
  315. ]
  316. },
  317. oldform: {},
  318. loading: false,
  319. subLoading: false,
  320. pageLoading: false,
  321. showBut: true
  322. };
  323. },
  324. props: {
  325. detailData: {
  326. type: Object
  327. }
  328. },
  329. created() {
  330. if (this.detailData.id) {
  331. this.getDetail(this.detailData.id);
  332. }
  333. if (this.detailData.status == 1) {
  334. this.option.disabled = true;
  335. }
  336. },
  337. filters: {},
  338. methods: {
  339. getDetail(id) {
  340. this.loading = true;
  341. this.showBut = false;
  342. this.pageLoading = true;
  343. detail(id)
  344. .then(res => {
  345. this.form = res.data.data;
  346. this.oldform = res.data.data;
  347. })
  348. .finally(() => {
  349. this.loading = false;
  350. this.showBut = true;
  351. this.pageLoading = false;
  352. });
  353. },
  354. //修改提交触发
  355. editCustomer(status) {
  356. this.$refs["form"].validate((valid, done) => {
  357. done();
  358. if (valid) {
  359. this.subLoading = true;
  360. this.form.tradeType = "CK";
  361. this.configuration.dicData.forEach(e => {
  362. if (this.form.corpId == e.id) {
  363. this.form.corpName = e.cname;
  364. }
  365. });
  366. submit({
  367. ...this.form
  368. })
  369. .then(res => {
  370. if (res.data.code == 200) {
  371. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  372. this.form = res.data.data;
  373. this.oldform = res.data.data;
  374. if (status == "goBack") {
  375. this.$emit("goBack");
  376. }
  377. }
  378. })
  379. .finally(() => {
  380. this.subLoading = false;
  381. });
  382. } else {
  383. return false;
  384. }
  385. });
  386. },
  387. //返回列表
  388. backToList() {
  389. if (contrastObj(this.form, this.oldform)) {
  390. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  391. confirmButtonText: "确定",
  392. cancelButtonText: "取消",
  393. type: "warning"
  394. })
  395. .then(() => {
  396. this.editCustomer("goBack");
  397. })
  398. .catch(() => {
  399. this.$emit("goBack");
  400. });
  401. } else {
  402. this.$emit("goBack");
  403. }
  404. },
  405. openReport() {
  406. this.switchDialog = !this.switchDialog;
  407. },
  408. onClose(val) {
  409. this.switchDialog = val;
  410. },
  411. getGoodsRow(row) {
  412. this.form.itemId = row.id;
  413. this.form.code = row.code;
  414. this.form.specs = row.specs;
  415. },
  416. returnRow(rows) {
  417. this.form.itemId = rows[0].id;
  418. this.form.code = rows[0].code;
  419. this.form.specs = rows[0].specs;
  420. }
  421. }
  422. };
  423. </script>
  424. <style lang="scss" scoped>
  425. ::v-deep .el-form-item {
  426. margin-bottom: 8px;
  427. }
  428. ::v-deep .el-form-item__error {
  429. display: none;
  430. }
  431. ::v-deep .select-component {
  432. display: flex;
  433. }
  434. </style>