BUG 30387
This commit is contained in:
		| @@ -0,0 +1,73 @@ | |||||||
|  | <template> | ||||||
|  |   <section class="AiEditInput" :class="{[align]:true,error}"> | ||||||
|  |     <el-input v-if="edit" size="small" v-model="content" @change="handleChange" @blur="cancel" clearable autofocus/> | ||||||
|  |     <div class="valueText" v-else v-text="value" @click="edit=true"/> | ||||||
|  |   </section> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: "AiEditInput", | ||||||
|  |   model: { | ||||||
|  |     prop: "value", | ||||||
|  |     event: "change" | ||||||
|  |   }, | ||||||
|  |   props: { | ||||||
|  |     value: {default: ""}, | ||||||
|  |     align: {default: ""}, | ||||||
|  |     error: Boolean | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       edit: false, | ||||||
|  |       content: "" | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     cancel() { | ||||||
|  |       this.edit = false | ||||||
|  |     }, | ||||||
|  |     handleChange(v) { | ||||||
|  |       this.$emit('change', v) | ||||||
|  |       this.$emit('update:error', false) | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   watch: { | ||||||
|  |     edit(v) { | ||||||
|  |       v && (this.content = this.$copy(this.value)) | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <style lang="scss" scoped> | ||||||
|  | ::v-deep.AiEditInput { | ||||||
|  |   &.error { | ||||||
|  |     background: rgba(#f46, .2); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   input { | ||||||
|  |     text-align: center; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .valueText { | ||||||
|  |     width: 100%; | ||||||
|  |     height: 100%; | ||||||
|  |     min-height: 32px; | ||||||
|  |     display: flex; | ||||||
|  |     align-items: center; | ||||||
|  |     justify-content: center; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   &.left { | ||||||
|  |     input { | ||||||
|  |       text-align: left | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     .valueText { | ||||||
|  |       justify-content: flex-start; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </style> | ||||||
| @@ -6,7 +6,7 @@ | |||||||
|     <template slot="content"> |     <template slot="content"> | ||||||
|       <ai-search-bar class="search-bar"> |       <ai-search-bar class="search-bar"> | ||||||
|         <template #left> |         <template #left> | ||||||
|           <el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加模块</el-button> |           <el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd()">添加模块</el-button> | ||||||
|         </template> |         </template> | ||||||
|       </ai-search-bar> |       </ai-search-bar> | ||||||
|       <ai-table |       <ai-table | ||||||
| @@ -21,46 +21,25 @@ | |||||||
|           <template slot-scope="{ row }"> |           <template slot-scope="{ row }"> | ||||||
|             <div class="table-options"> |             <div class="table-options"> | ||||||
|               <el-button type="text" @click="toAdd(row.id)">编辑</el-button> |               <el-button type="text" @click="toAdd(row.id)">编辑</el-button> | ||||||
|               <el-button type="text" @click="moduleId = row.id, form.moduleId = row.id, getCateList(),  isShowAdd = true">分类</el-button> |               <el-button type="text" @click="getCateList(row.id),isShowAdd = true">分类</el-button> | ||||||
|               <el-button type="text" @click="remove(row.id)">删除</el-button> |               <el-button type="text" @click="remove(row.id)">删除</el-button> | ||||||
|             </div> |             </div> | ||||||
|           </template> |           </template> | ||||||
|         </el-table-column> |         </el-table-column> | ||||||
|       </ai-table> |       </ai-table> | ||||||
|       <ai-dialog |       <ai-dialog :visible.sync="isShowAdd" width="880px" height="580px" title="文章分类" @close="onClose" @onConfirm="submitCategory"> | ||||||
|           :visible.sync="isShowAdd" |         <el-button icon="iconfont iconAdd" type="text" @click="cateList.push({error:false,categoryName:null})">添加分类</el-button> | ||||||
|           width="880px" |         <ai-table v-if="moduleId" :tableData="cateList" :col-configs="cateColConfigs" :isShowPagination="false" @getList="getCateList"> | ||||||
|           height="580px" |           <el-table-column slot="category" label="分类名称" align="center"> | ||||||
|           title="文章分类" |             <template slot-scope="{row}"> | ||||||
|           @close="onClose" |               <ai-edit-input v-model="row.categoryName" :error.sync="row.error"/> | ||||||
|           @onConfirm="onConfirm(false)"> |             </template> | ||||||
|         <el-form ref="form" class="ai-form" :model="form" label-width="110px" label-position="right"> |           </el-table-column> | ||||||
|           <el-form-item label="分类名称" style="width: 500px;" prop="categoryName" :rules="[{ required: true, message: '请输入分类名称', trigger: 'blur' }]"> |  | ||||||
|             <div class="catewrapper"> |  | ||||||
|               <el-input size="small" style="width: 300px;" placeholder="请输入分类名称" v-model="form.categoryName"> |  | ||||||
|               </el-input> |  | ||||||
|               <el-button style="margin-left: 20px;" size="small" type="primary" icon="iconfont iconAdd" v-if="!id" @click="onConfirm(true)">添加</el-button> |  | ||||||
|             </div> |  | ||||||
|           </el-form-item> |  | ||||||
|         </el-form> |  | ||||||
|         <ai-table |  | ||||||
|             v-if="!id" |  | ||||||
|             class="detail-table__table" |  | ||||||
|             :border="true" |  | ||||||
|             tableSize="small" |  | ||||||
|             :total="cateTotal" |  | ||||||
|             :tableData="cateList" |  | ||||||
|             :col-configs="cateColConfigs" |  | ||||||
|             :current.sync="cateSearch.current" |  | ||||||
|             :size.sync="cateSearch.size" |  | ||||||
|             :stripe="false" |  | ||||||
|             @getList="getCateList"> |  | ||||||
|           <el-table-column slot="options" width="220px" fixed="right" label="操作" align="center"> |           <el-table-column slot="options" width="220px" fixed="right" label="操作" align="center"> | ||||||
|             <template slot-scope="{ row }"> |             <template slot-scope="{ row,$index }"> | ||||||
|               <div class="table-options"> |               <el-button type="text" @click="handleMove(row,$index,-1)" :disabled="$index==0">上移</el-button> | ||||||
|                 <el-button type="text" @click="id = row.id, form.categoryName = row.categoryName">编辑</el-button> |               <el-button type="text" @click="handleMove(row,$index,1)" :disabled="$index==(cateList.length-1)">下移</el-button> | ||||||
|                 <el-button type="text" @click="removeCate(row.id)">删除</el-button> |               <el-button type="text" @click="removeCate($index)">删除</el-button> | ||||||
|               </div> |  | ||||||
|             </template> |             </template> | ||||||
|           </el-table-column> |           </el-table-column> | ||||||
|         </ai-table> |         </ai-table> | ||||||
| @@ -70,9 +49,11 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
|  | import AiEditInput from "./AiEditInput"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   name: 'List', |   name: 'List', | ||||||
|  |   components: {AiEditInput}, | ||||||
|   props: { |   props: { | ||||||
|     instance: Function, |     instance: Function, | ||||||
|     dict: Object |     dict: Object | ||||||
| @@ -86,10 +67,6 @@ export default { | |||||||
|         title: '' |         title: '' | ||||||
|       }, |       }, | ||||||
|       moduleId: '', |       moduleId: '', | ||||||
|       cateSearch: { |  | ||||||
|         current: 1, |  | ||||||
|         size: 10 |  | ||||||
|       }, |  | ||||||
|       total: 10, |       total: 10, | ||||||
|       cateList: [], |       cateList: [], | ||||||
|       colConfigs: [ |       colConfigs: [ | ||||||
| @@ -100,17 +77,10 @@ export default { | |||||||
|         {prop: 'isComment', label: '是否可以评论', align: 'center', dict: 'yesOrNo'} |         {prop: 'isComment', label: '是否可以评论', align: 'center', dict: 'yesOrNo'} | ||||||
|       ], |       ], | ||||||
|       cateColConfigs: [ |       cateColConfigs: [ | ||||||
|         {prop: 'showIndex', label: '排序', align: 'center', width: 80}, |         {type: 'index', label: "排序", align: 'center'}, | ||||||
|         {prop: 'categoryName', label: '分类名称', align: 'center'} |         {slot: 'category'} | ||||||
|       ], |       ], | ||||||
|       form: { |  | ||||||
|         categoryName: '', |  | ||||||
|         moduleId: '', |  | ||||||
|         showIndex: 1 |  | ||||||
|       }, |  | ||||||
|       cateTotal: 0, |  | ||||||
|       isShowAdd: false, |       isShowAdd: false, | ||||||
|       id: '', |  | ||||||
|       tableData: [] |       tableData: [] | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| @@ -132,33 +102,26 @@ export default { | |||||||
|         } |         } | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|  |     getCateList(moduleId) { | ||||||
|     getCateList() { |       this.moduleId = moduleId | ||||||
|       this.instance.post(`/app/appcontentmodulecategory/list`, null, { |       this.instance.post(`/app/appcontentmodulecategory/list`, null, { | ||||||
|         params: { |         params: {size: 99999, moduleId} | ||||||
|           ...this.cateSearch, |  | ||||||
|           moduleId: this.moduleId |  | ||||||
|         } |  | ||||||
|       }).then(res => { |       }).then(res => { | ||||||
|         if (res.code == 0) { |         if (res?.data) { | ||||||
|           this.cateList = res.data.records |           this.cateList = res.data.records.map(e => ({...e, error: false})) | ||||||
|           this.cateTotal = res.data.total |  | ||||||
|         } |         } | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|  |     removeCate(i) { | ||||||
|     removeCate(id) { |  | ||||||
|       this.$confirm('确定删除该数据?').then(() => { |       this.$confirm('确定删除该数据?').then(() => { | ||||||
|         this.instance.post(`/app/appcontentmodulecategory/delete?ids=${id}`).then(res => { |         this.cateList.splice(i, 1) | ||||||
|           if (res.code == 0) { |  | ||||||
|             this.$message.success('删除成功!') |  | ||||||
|             this.getList() |  | ||||||
|             this.getCateList() |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|  |     handleMove(row, i, forward) { | ||||||
|  |       const tmp = this.$copy(row), target = i + forward | ||||||
|  |       this.cateList.splice(i, 1, this.cateList[target]) | ||||||
|  |       this.cateList.splice(target, 1, tmp) | ||||||
|  |     }, | ||||||
|     remove(id) { |     remove(id) { | ||||||
|       this.$confirm('确定删除该数据?').then(() => { |       this.$confirm('确定删除该数据?').then(() => { | ||||||
|         this.instance.post(`/app/appcontentmoduleinfo/delete?ids=${id}`).then(res => { |         this.instance.post(`/app/appcontentmoduleinfo/delete?ids=${id}`).then(res => { | ||||||
| @@ -169,50 +132,35 @@ export default { | |||||||
|         }) |         }) | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|  |     submitCategory() { | ||||||
|     onConfirm(flag) { |       if (!this.cateList.some((e, i, arr) => { | ||||||
|       if (!flag && !this.id) { |         arr[i].error = !e.categoryName | ||||||
|         this.isShowAdd = false |         if (!e.categoryName) { | ||||||
|  |           this.$message.error(`第${i + 1}行未填写分类名称!`) | ||||||
|         return false |           return true | ||||||
|       } |  | ||||||
|  |  | ||||||
|       this.$refs.form.validate((valid) => { |  | ||||||
|         if (valid) { |  | ||||||
|           this.instance.post(`/app/appcontentmodulecategory/addOrUpdate`, { |  | ||||||
|             ...this.form, |  | ||||||
|             id: this.id || '' |  | ||||||
|           }).then(res => { |  | ||||||
|             if (res.code == 0) { |  | ||||||
|               this.$message.success('提交成功') |  | ||||||
|               this.getList() |  | ||||||
|               this.getCateList() |  | ||||||
|               this.form.categoryName = '' |  | ||||||
|  |  | ||||||
|               if (this.id) { |  | ||||||
|                 this.id = '' |  | ||||||
|  |  | ||||||
|                 return false |  | ||||||
|               } |  | ||||||
|             } |  | ||||||
|           }) |  | ||||||
|         } |         } | ||||||
|       }) |       })) { | ||||||
|  |         const {cateList: categorys, moduleId} = this | ||||||
|  |         this.instance.post(`/app/appcontentmodulecategory/addOrUpdate2`, { | ||||||
|  |           categorys, moduleId | ||||||
|  |         }).then(res => { | ||||||
|  |           if (res?.code == 0) { | ||||||
|  |             this.$message.success('提交成功') | ||||||
|  |             this.isShowAdd = false | ||||||
|  |             this.getList() | ||||||
|  |           } | ||||||
|  |         }) | ||||||
|  |       } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     onClose() { |     onClose() { | ||||||
|       this.id = '' |  | ||||||
|       this.moduleId = '' |       this.moduleId = '' | ||||||
|       this.form.categoryName = '' |       this.cateList = [] | ||||||
|       this.form.moduleId = '' |  | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     toAdd(id) { |     toAdd(id) { | ||||||
|       this.$emit('change', { |       this.$emit('change', { | ||||||
|         type: 'Add', |         type: 'Add', | ||||||
|         params: { |         params: {id} | ||||||
|           id: id || '' |  | ||||||
|         } |  | ||||||
|       }) |       }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user