detailsPage.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 class="el-button--small-yh" type="primary" size="small" @click="editCustomer">保存数据
  14. </el-button>
  15. <el-button class="el-button--small-yh" type="primary" size="small" @click="enableNot" v-if="form.id">
  16. {{ form.enableOrNot == 0 ? '启用' : '禁用' }}
  17. </el-button>
  18. </div>
  19. </div>
  20. <div style="margin-top: 50px">
  21. <trade-card title="基础信息">
  22. <avue-form class="trading-form" :option="optionForm" v-model="form" ref="form"></avue-form>
  23. </trade-card>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { typeSave, detail, editenable } from "@/api/tirePartsMall/basicData/accountManagement";
  29. export default {
  30. name: "detailsPage",
  31. data() {
  32. return {
  33. form: {},
  34. optionForm: {
  35. menuBtn: false,
  36. span: 8,
  37. column: [{
  38. label: '账户名称',
  39. prop: "cname",
  40. rules: [{
  41. required: true,
  42. message: " ",
  43. trigger: "blur"
  44. }]
  45. }, {
  46. label: '账户类型',
  47. prop: "accountType",
  48. type: 'select',
  49. dicUrl: "/api/blade-system/dict-biz/dictionary?code=accountType",
  50. props: {
  51. label: "dictValue",
  52. value: "dictValue"
  53. }
  54. }, {
  55. label: '开户银行',
  56. prop: "bankDeposit"
  57. }, {
  58. label: '银行账号',
  59. prop: "bankAccount"
  60. }, {
  61. label: '开户人',
  62. prop: "accountHolder"
  63. }, {
  64. label: '公司名称',
  65. prop: "corporateName",
  66. type: 'select',
  67. dicUrl: "/api/blade-system/dept/lazy-list?parentId=",
  68. props: {
  69. label: "deptName",
  70. value: "id"
  71. }
  72. }, {
  73. label: '币别',
  74. prop: "currency",
  75. span: 8,
  76. type: 'select',
  77. dicData: [
  78. {
  79. label: "CNY",
  80. value: "CNY",
  81. },
  82. {
  83. label: "USD",
  84. value: "USD",
  85. }
  86. ],
  87. }, {
  88. label: '账户余额',
  89. prop: "accountBalance",
  90. disabled: true
  91. }, {
  92. label: '备注',
  93. prop: "remarks",
  94. type: 'textarea',
  95. span: 24,
  96. minRows: 2
  97. }]
  98. }
  99. }
  100. },
  101. props: {
  102. onLoad: {
  103. type: Object
  104. },
  105. detailData: {
  106. type: Object
  107. }
  108. },
  109. async created() {
  110. if (this.onLoad.id) {
  111. this.queryData(this.onLoad.id)
  112. }
  113. },
  114. methods: {
  115. //启用禁用
  116. enableNot() {
  117. let data = this.form
  118. editenable({ id: data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {
  119. this.$message({
  120. type: "success",
  121. message: data.enableOrNot ? "禁用成功!" : "启用成功!"
  122. });
  123. this.$set(this.form, 'enableOrNot', data.enableOrNot == 1 ? 0 : 1)
  124. })
  125. },
  126. // 查询
  127. queryData(id) {
  128. const loading = this.$loading({
  129. lock: true,
  130. text: '加载中',
  131. spinner: 'el-icon-loading',
  132. background: 'rgba(255,255,255,0.7)'
  133. })
  134. detail({ id }).then(res => {
  135. this.form = res.data.data;
  136. loading.close()
  137. }).finally(() => {
  138. loading.close()
  139. });
  140. },
  141. editCustomer() {
  142. this.$refs["form"].validate((valid, done) => {
  143. done();
  144. if (valid) {
  145. const loading = this.$loading({
  146. lock: true,
  147. text: '加载中',
  148. spinner: 'el-icon-loading',
  149. background: 'rgba(255,255,255,0.7)'
  150. })
  151. if (!this.form.id && !this.form.enableOrNot) {
  152. this.form.enableOrNot = 1;
  153. }
  154. typeSave(this.form).then(res => {
  155. loading.close()
  156. this.$message({
  157. type: "success",
  158. message: this.form.id ? "修改成功!" : "新增成功!"
  159. });
  160. this.queryData(res.data.data.id);
  161. if (!this.form.id) {
  162. //添加成功后默认启用
  163. let data = this.form
  164. // editenable({ id: res.data.data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {
  165. // this.$set(this.form, 'enableOrNot', data.enableOrNot == 1 ? 0 : 1)
  166. // })
  167. }
  168. }).finally(() => {
  169. loading.close()
  170. });
  171. }
  172. })
  173. },
  174. backToList(type) {
  175. this.$emit("backToList", type);
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .trading-form ::v-deep .el-form-item {
  182. margin-bottom: 8px !important;
  183. }
  184. </style>