codeEdit.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. width="50%"
  5. :visible.sync="showEditFlag"
  6. :close-on-click-modal="false"
  7. custom-class="ele-dialog-form"
  8. append-to-body
  9. @close="cancel"
  10. :title="title + '编码'"
  11. >
  12. <el-form ref="form" :model="form" :rules="rules" label-width="82px">
  13. <el-row :gutter="15">
  14. <el-col :span="12">
  15. <el-form-item label="名称" prop="name">
  16. <el-input v-model="form.name" placeholder="请输入"></el-input>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="12">
  20. <el-form-item label="描述" prop="remark">
  21. <el-input
  22. v-model="form.remark"
  23. type="textarea"
  24. placeholder="请输入"
  25. ></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="24">
  29. <el-form-item label="使用对象" prop="useObjList">
  30. <tree ref="treeRef"></tree>
  31. </el-form-item>
  32. </el-col>
  33. <!-- <el-col :span="24">
  34. <el-form-item label="创建人" prop="remark">
  35. <el-input
  36. v-model="form.remark"
  37. type="textarea"
  38. placeholder="请输入"
  39. ></el-input>
  40. </el-form-item>
  41. </el-col> -->
  42. </el-row>
  43. </el-form>
  44. <template v-slot:footer>
  45. <el-button @click="cancel">取消</el-button>
  46. <el-button type="primary" :loading="loading" @click="save">
  47. 确认
  48. </el-button>
  49. </template>
  50. </ele-modal>
  51. </template>
  52. <script>
  53. const defaultForm = {
  54. name: '', //名称
  55. parentId: '', //父id
  56. sort: '',
  57. status: '', //状态
  58. type: 2, //类型
  59. useObjList: [], //使用对象信息集合
  60. remark: '' //备注
  61. };
  62. import { save } from '@/api/businessCode';
  63. import tree from './tree.vue';
  64. export default {
  65. data() {
  66. return {
  67. // 表单数据
  68. form: { ...defaultForm },
  69. // 表单验证规则
  70. rules: {},
  71. // 提交状态
  72. loading: false,
  73. showEditFlag: false,
  74. title: '',
  75. type: '',
  76. rules: {
  77. name: [
  78. {
  79. required: true,
  80. message: '请输入',
  81. trigger: 'blur'
  82. }
  83. ]
  84. }
  85. };
  86. },
  87. props: {
  88. parentId: ''
  89. },
  90. components: {
  91. tree
  92. },
  93. created() {},
  94. methods: {
  95. async open(type, row) {
  96. this.title = type === 'edit' ? '编辑' : '新增';
  97. this.showEditFlag = true;
  98. this.type = type;
  99. if (type == 'add') {
  100. this.form.parentId = this.parentId;
  101. } else {
  102. this.form = JSON.parse(JSON.stringify(row));
  103. }
  104. console.log(this.form, 'row');
  105. this.$nextTick(() => {
  106. this.$refs.treeRef.init(this.form.useObjList || []);
  107. });
  108. },
  109. /* 保存编辑 */
  110. save() {
  111. this.$refs.form.validate(async (valid) => {
  112. if (!valid) {
  113. return false;
  114. }
  115. if (this.type != 'edit') {
  116. delete this.form.id;
  117. }
  118. this.form.useObjList = this.$refs.treeRef.getList();
  119. this.loading = true;
  120. save(this.form)
  121. .then((msg) => {
  122. this.loading = false;
  123. this.cancel();
  124. this.$emit('done');
  125. })
  126. .catch((e) => {
  127. this.loading = false;
  128. });
  129. });
  130. },
  131. cancel() {
  132. this.form = { ...defaultForm };
  133. this.$refs.form.clearValidate();
  134. this.showEditFlag = false;
  135. }
  136. }
  137. };
  138. </script>
  139. <style scoped lang="scss">
  140. .aaa {
  141. width: 100%;
  142. ::v-deep .upload-demo {
  143. width: 100%;
  144. .el-upload--text {
  145. width: 100%;
  146. button {
  147. width: 100%;
  148. background: #ffffff;
  149. border: 1px solid #dbdbdb;
  150. border-radius: 5px;
  151. }
  152. }
  153. .el-upload-list {
  154. transform: translate(10px, -39px);
  155. position: absolute;
  156. }
  157. }
  158. }
  159. </style>