detailsPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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: "taxRate",
  197. span: 8
  198. },
  199. {
  200. label: "商品类别",
  201. prop: "goodsTypeName",
  202. span: 8
  203. },
  204. {
  205. label: "状态",
  206. prop: "status",
  207. type: "select",
  208. dicData: orderStates,
  209. props: {
  210. label: "name",
  211. value: "code"
  212. },
  213. rules: [
  214. {
  215. required: true,
  216. message: "",
  217. trigger: "blur"
  218. }
  219. ],
  220. span: 8
  221. },
  222. {
  223. label: "有效期开始",
  224. prop: "startTime",
  225. type: "date",
  226. format: "yyyy-MM-dd",
  227. valueFormat: "yyyy-MM-dd 00:00:00",
  228. rules: [
  229. {
  230. required: true,
  231. message: "",
  232. trigger: "blur"
  233. }
  234. ],
  235. span: 8
  236. },
  237. {
  238. label: "有效期结束",
  239. prop: "endTime",
  240. type: "date",
  241. format: "yyyy-MM-dd",
  242. valueFormat: "yyyy-MM-dd 23:59:59",
  243. rules: [
  244. {
  245. required: true,
  246. message: "",
  247. trigger: "blur"
  248. }
  249. ],
  250. span: 8
  251. },
  252. {
  253. label: "业务员",
  254. prop: "person",
  255. span: 8,
  256. row: true
  257. },
  258. {
  259. label: "历史价格1",
  260. prop: "priceOne",
  261. span: 8,
  262. disabled: true
  263. },
  264. {
  265. label: "历史日期1",
  266. prop: "priceOneTime",
  267. type: "datetime",
  268. format: "yyyy-MM-dd hh:mm:ss",
  269. valueFormat: "yyyy-MM-dd hh:mm:ss",
  270. span: 8,
  271. disabled: true
  272. },
  273. {
  274. label: "历史价格2",
  275. prop: "priceTwo",
  276. span: 8,
  277. disabled: true
  278. },
  279. {
  280. label: "历史日期2",
  281. prop: "priceTwoTime",
  282. type: "datetime",
  283. format: "yyyy-MM-dd hh:mm:ss",
  284. valueFormat: "yyyy-MM-dd hh:mm:ss",
  285. span: 8,
  286. disabled: true
  287. },
  288. {
  289. label: "历史价格3",
  290. prop: "priceThree",
  291. span: 8,
  292. disabled: true
  293. },
  294. {
  295. label: "历史日期3",
  296. prop: "priceThreeTime",
  297. type: "datetime",
  298. format: "yyyy-MM-dd hh:mm:ss",
  299. valueFormat: "yyyy-MM-dd hh:mm:ss",
  300. span: 8,
  301. disabled: true
  302. },
  303. {
  304. label: "备注",
  305. prop: "remarks",
  306. type: "textarea",
  307. minRows: 2,
  308. span: 24
  309. }
  310. ]
  311. },
  312. oldform: {},
  313. loading: false,
  314. subLoading: false,
  315. pageLoading: false,
  316. showBut: true
  317. };
  318. },
  319. props: {
  320. detailData: {
  321. type: Object
  322. }
  323. },
  324. created() {
  325. if (this.detailData.id) {
  326. this.getDetail(this.detailData.id);
  327. }
  328. if (this.detailData.status == 1) {
  329. this.option.disabled = true;
  330. }
  331. },
  332. filters: {},
  333. methods: {
  334. getDetail(id) {
  335. this.loading = true;
  336. this.showBut = false;
  337. this.pageLoading = true;
  338. detail(id)
  339. .then(res => {
  340. this.form = res.data.data;
  341. this.oldform = res.data.data;
  342. })
  343. .finally(() => {
  344. this.loading = false;
  345. this.showBut = true;
  346. this.pageLoading = false;
  347. });
  348. },
  349. //修改提交触发
  350. editCustomer(status) {
  351. this.$refs["form"].validate((valid, done) => {
  352. done();
  353. if (valid) {
  354. this.subLoading = true;
  355. this.form.tradeType = "CK";
  356. this.configuration.dicData.forEach(e => {
  357. if (this.form.corpId == e.id) {
  358. this.form.corpName = e.cname;
  359. }
  360. });
  361. submit({
  362. ...this.form
  363. })
  364. .then(res => {
  365. if (res.data.code == 200) {
  366. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  367. this.form = res.data.data;
  368. this.oldform = res.data.data;
  369. if (status == "goBack") {
  370. this.$emit("goBack");
  371. }
  372. }
  373. })
  374. .finally(() => {
  375. this.subLoading = false;
  376. });
  377. } else {
  378. return false;
  379. }
  380. });
  381. },
  382. //返回列表
  383. backToList() {
  384. if (contrastObj(this.form, this.oldform)) {
  385. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  386. confirmButtonText: "确定",
  387. cancelButtonText: "取消",
  388. type: "warning"
  389. })
  390. .then(() => {
  391. this.editCustomer("goBack");
  392. })
  393. .catch(() => {
  394. this.$emit("goBack");
  395. });
  396. } else {
  397. this.$emit("goBack");
  398. }
  399. },
  400. openReport() {
  401. this.switchDialog = !this.switchDialog;
  402. },
  403. onClose(val) {
  404. this.switchDialog = val;
  405. },
  406. getGoodsRow(row) {
  407. this.form.itemId = row.id;
  408. this.form.code = row.code;
  409. this.form.specs = row.specs;
  410. },
  411. returnRow(rows) {
  412. this.form.itemId = rows[0].id;
  413. this.form.code = rows[0].code;
  414. this.form.specs = rows[0].specs;
  415. }
  416. }
  417. };
  418. </script>
  419. <style lang="scss" scoped>
  420. ::v-deep .el-form-item {
  421. margin-bottom: 8px;
  422. }
  423. ::v-deep .el-form-item__error {
  424. display: none;
  425. }
  426. ::v-deep .select-component {
  427. display: flex;
  428. }
  429. </style>