detailsPage.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. span: 8
  132. },
  133. {
  134. label: "FOB系数",
  135. prop: "coefficient",
  136. rules: [
  137. {
  138. required: true,
  139. message: "",
  140. trigger: "blur"
  141. }
  142. ],
  143. span: 8
  144. },
  145. {
  146. label: "价格类型",
  147. prop: "billType",
  148. rules: [
  149. {
  150. required: true,
  151. message: "",
  152. trigger: "blur"
  153. }
  154. ],
  155. type: "select",
  156. dicUrl: "/api/blade-system/dict-biz/dictionary?code=billType",
  157. props: {
  158. label: "dictValue",
  159. value: "dictKey"
  160. },
  161. span: 8
  162. },
  163. {
  164. label: "最新价格",
  165. prop: "price",
  166. rules: [
  167. {
  168. required: true,
  169. message: "",
  170. trigger: "blur"
  171. }
  172. ],
  173. span: 8
  174. },
  175. {
  176. label: "状态",
  177. prop: "status",
  178. type: "select",
  179. dicData: orderStates,
  180. props: {
  181. label: "name",
  182. value: "code"
  183. },
  184. rules: [
  185. {
  186. required: true,
  187. message: "",
  188. trigger: "blur"
  189. }
  190. ],
  191. span: 8
  192. },
  193. {
  194. label: "有效期开始",
  195. prop: "startTime",
  196. type: "date",
  197. format: "yyyy-MM-dd",
  198. valueFormat: "yyyy-MM-dd 00:00:00",
  199. rules: [
  200. {
  201. required: true,
  202. message: "",
  203. trigger: "blur"
  204. }
  205. ],
  206. span: 8
  207. },
  208. {
  209. label: "有效期结束",
  210. prop: "endTime",
  211. type: "date",
  212. format: "yyyy-MM-dd",
  213. valueFormat: "yyyy-MM-dd 23:59:59",
  214. rules: [
  215. {
  216. required: true,
  217. message: "",
  218. trigger: "blur"
  219. }
  220. ],
  221. span: 8
  222. },
  223. {
  224. label: "业务员",
  225. prop: "person",
  226. span: 8,
  227. row: true
  228. },
  229. {
  230. label: "历史价格1",
  231. prop: "priceOne",
  232. span: 8,
  233. disabled: true
  234. },
  235. {
  236. label: "历史日期1",
  237. prop: "priceOneTime",
  238. type: "datetime",
  239. format: "yyyy-MM-dd hh:mm:ss",
  240. valueFormat: "yyyy-MM-dd hh:mm:ss",
  241. span: 8,
  242. disabled: true
  243. },
  244. {
  245. label: "历史价格2",
  246. prop: "priceTwo",
  247. span: 8,
  248. disabled: true
  249. },
  250. {
  251. label: "历史日期2",
  252. prop: "priceTwoTime",
  253. type: "datetime",
  254. format: "yyyy-MM-dd hh:mm:ss",
  255. valueFormat: "yyyy-MM-dd hh:mm:ss",
  256. span: 8,
  257. disabled: true
  258. },
  259. {
  260. label: "历史价格3",
  261. prop: "priceThree",
  262. span: 8,
  263. disabled: true
  264. },
  265. {
  266. label: "历史日期3",
  267. prop: "priceThreeTime",
  268. type: "datetime",
  269. format: "yyyy-MM-dd hh:mm:ss",
  270. valueFormat: "yyyy-MM-dd hh:mm:ss",
  271. span: 8,
  272. disabled: true
  273. },
  274. {
  275. label: "备注",
  276. prop: "remarks",
  277. type: "textarea",
  278. minRows: 2,
  279. span: 24
  280. }
  281. ]
  282. },
  283. oldform: {},
  284. loading: false,
  285. subLoading: false,
  286. pageLoading: false,
  287. showBut: true
  288. };
  289. },
  290. props: {
  291. detailData: {
  292. type: Object
  293. }
  294. },
  295. created() {
  296. if (this.detailData.id) {
  297. this.getDetail(this.detailData.id);
  298. }
  299. if (this.detailData.status == 1) {
  300. this.option.disabled = true;
  301. }
  302. },
  303. filters: {},
  304. methods: {
  305. getDetail(id) {
  306. this.loading = true;
  307. this.showBut = false;
  308. this.pageLoading = true;
  309. detail(id)
  310. .then(res => {
  311. this.form = res.data.data;
  312. this.oldform = res.data.data;
  313. })
  314. .finally(() => {
  315. this.loading = false;
  316. this.showBut = true;
  317. this.pageLoading = false;
  318. });
  319. },
  320. //修改提交触发
  321. editCustomer(status) {
  322. this.$refs["form"].validate((valid, done) => {
  323. done();
  324. if (valid) {
  325. this.subLoading = true;
  326. this.form.tradeType = "CK";
  327. this.configuration.dicData.forEach(e => {
  328. if (this.form.corpId == e.id) {
  329. this.form.corpName = e.cname;
  330. }
  331. });
  332. submit({
  333. ...this.form
  334. })
  335. .then(res => {
  336. if (res.data.code == 200) {
  337. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  338. this.form = res.data.data;
  339. this.oldform = res.data.data;
  340. if (status == "goBack") {
  341. this.$emit("goBack");
  342. }
  343. }
  344. })
  345. .finally(() => {
  346. this.subLoading = false;
  347. });
  348. } else {
  349. return false;
  350. }
  351. });
  352. },
  353. //返回列表
  354. backToList() {
  355. if (contrastObj(this.form, this.oldform)) {
  356. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  357. confirmButtonText: "确定",
  358. cancelButtonText: "取消",
  359. type: "warning"
  360. })
  361. .then(() => {
  362. this.editCustomer("goBack");
  363. })
  364. .catch(() => {
  365. this.$emit("goBack");
  366. });
  367. } else {
  368. this.$emit("goBack");
  369. }
  370. },
  371. openReport() {
  372. this.switchDialog = !this.switchDialog;
  373. },
  374. onClose(val) {
  375. this.switchDialog = val;
  376. },
  377. getGoodsRow(row) {
  378. this.form.itemId = row.id;
  379. this.form.code = row.code;
  380. this.form.specs = row.specs;
  381. },
  382. returnRow(rows) {
  383. this.form.itemId = rows[0].id;
  384. this.form.code = rows[0].code;
  385. this.form.specs = rows[0].specs;
  386. }
  387. }
  388. };
  389. </script>
  390. <style lang="scss" scoped>
  391. .customer-head {
  392. position: fixed;
  393. top: 105px;
  394. width: 100%;
  395. margin-left: -10px;
  396. height: 62px;
  397. background: #ffffff;
  398. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  399. z-index: 999;
  400. }
  401. .customer-back {
  402. cursor: pointer;
  403. line-height: 62px;
  404. font-size: 16px;
  405. color: #323233;
  406. font-weight: 400;
  407. }
  408. .back-icon {
  409. line-height: 64px;
  410. font-size: 20px;
  411. margin-right: 8px;
  412. }
  413. .sell-customer-btn {
  414. position: fixed;
  415. right: 244px;
  416. top: 115px;
  417. }
  418. .copy-customer-btn {
  419. position: fixed;
  420. right: 140px;
  421. top: 115px;
  422. }
  423. .add-customer-btn {
  424. position: fixed;
  425. right: 36px;
  426. top: 115px;
  427. }
  428. ::v-deep .el-form-item {
  429. margin-bottom: 8px;
  430. }
  431. ::v-deep .el-form-item__error {
  432. display: none;
  433. }
  434. ::v-deep .select-component {
  435. display: flex;
  436. }
  437. </style>