detailsPage.vue 10 KB

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