detailsPage.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList(0)">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <!-- <el-button class="el-button&#45;&#45;small-yh" style="margin-right: 10px" type="primary" size="small" v-if="!editButton"-->
  11. <!-- @click="confirmEditing">编辑-->
  12. <!-- </el-button>-->
  13. <el-button
  14. class="el-button--small-yh"
  15. type="primary"
  16. size="small"
  17. @click="editCustomer">保存数据
  18. </el-button>
  19. <el-button
  20. class="el-button--small-yh"
  21. type="primary"
  22. size="small"
  23. @click="enableNot"
  24. v-if="form.id">
  25. {{ form.enableOrNot == 0 ? '启用' : '禁用' }}
  26. </el-button>
  27. </div>
  28. </div>
  29. <div style="margin-top: 50px">
  30. <trade-card title="基础信息">
  31. <avue-form :option="optionForm" v-model="form" ref="form"></avue-form>
  32. </trade-card>
  33. <trade-card title="附件信息 (图片文件像素推荐700×400)">
  34. <c-upload
  35. basic
  36. :data="form.brandFilesList"
  37. :disabled="disabled"
  38. deleteUrl="/api/blade-sales-part/brandfiles/remove"
  39. :enumerationValue="272.1"
  40. display
  41. />
  42. <!-- <span style="font-size: 12px;">(图片文件像素推荐700X750,有且只允许有一张主图,其余均为副图)</span> -->
  43. </trade-card>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. // import {submit} from "@/api/tirePartsMall/basicData/customerInformation";
  49. import {submit, getDetails, updateEnableOrNot} from "@/api/tirePartsMall/basicData/brandPage";
  50. import it from "element-ui/src/locale/lang/it";
  51. export default {
  52. name: "detailsPage",
  53. data() {
  54. return {
  55. disabled: false,
  56. form: {
  57. brandFilesList: []
  58. },
  59. optionForm: {
  60. menuBtn: false,
  61. span: 8,
  62. column: [{
  63. label: '名称',
  64. prop: "cname",
  65. rules: [{
  66. required: true,
  67. message: " ",
  68. trigger: "blur"
  69. }]
  70. }, {
  71. label: '制单人',
  72. prop: "createUserName",
  73. disabled: true
  74. }, {
  75. label: '制单日期',
  76. prop: "createTime",
  77. disabled: true
  78. }, {
  79. label: '排序',
  80. prop: "sort",
  81. type:'number'
  82. }, {
  83. label: '备注',
  84. prop: "remarks",
  85. type: 'textarea',
  86. span: 24,
  87. minRows: 2
  88. }]
  89. },
  90. formContacts: {},
  91. }
  92. },
  93. props: {
  94. onLoad: Object,
  95. detailData: Object
  96. },
  97. async created() {
  98. if (this.onLoad.id && this.detailData.id) {
  99. this.refresh(this.onLoad.id, true)
  100. } else if (this.onLoad.id) {
  101. this.refresh(this.onLoad.id, true)
  102. }
  103. },
  104. methods: {
  105. refresh(id, type) {
  106. const loading = this.$loading({
  107. lock: true,
  108. text: '加载中',
  109. spinner: 'el-icon-loading',
  110. background: 'rgba(255,255,255,0.7)'
  111. })
  112. getDetails({id: id}).then(res => {
  113. this.form = res.data.data
  114. loading.close();
  115. }).catch(() => {
  116. loading.close();
  117. })
  118. },
  119. //是否启用
  120. enableNot() {
  121. const {brandFilesList, ...formWithoutBrandFilesList} = this.form;
  122. const loading = this.$loading({
  123. lock: true,
  124. text: '加载中',
  125. spinner: 'el-icon-loading',
  126. background: 'rgba(255,255,255,0.7)'
  127. })
  128. updateEnableOrNot({
  129. ...formWithoutBrandFilesList,
  130. enableOrNot: this.form.enableOrNot == 0 ? 1 : 0
  131. }).then(res => {
  132. loading.close()
  133. this.$message.success("操作成功")
  134. this.refresh(this.form.id)
  135. }).catch(() => {
  136. loading.close()
  137. })
  138. },
  139. //修改提交触发
  140. editCustomer() {
  141. if (this.form.brandFilesList.length === 0) {
  142. return this.$message.error("请上传主图")
  143. }
  144. let num = 0
  145. for (let item of this.form.brandFilesList) {
  146. if (item.version == 0) {
  147. num++
  148. }
  149. }
  150. if (num > 1) {
  151. return this.$message.error("主图类型重复")
  152. }
  153. this.$refs["form"].validate((valid, done) => {
  154. done();
  155. if (valid) {
  156. this.loadingBtn = true;
  157. this.form.type = 'LBT'
  158. submit({
  159. ...this.form
  160. }).then(res => {
  161. this.$message.success("保存成功");
  162. this.refresh(res.data.data.id)
  163. }).finally(() => {
  164. this.loadingBtn = false;
  165. });
  166. } else {
  167. return false;
  168. }
  169. });
  170. },
  171. //自定义列保存
  172. async saveColumnTwo(ref, option, optionBack, code) {
  173. /**
  174. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  175. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  176. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  177. */
  178. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  179. if (inSave) {
  180. this.$message.success("保存成功");
  181. //关闭窗口
  182. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  183. }
  184. },
  185. //自定义列重置
  186. async resetColumnTwo(ref, option, optionBack, code) {
  187. this[option] = this[optionBack];
  188. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  189. if (inSave) {
  190. this.$message.success("重置成功");
  191. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  192. }
  193. },
  194. backToList(type) {
  195. this.$emit("backToList", type);
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. ::v-deep .el-form-item {
  202. margin-bottom: 8px !important;
  203. }
  204. </style>