BUG 30988
This commit is contained in:
		| @@ -12,13 +12,14 @@ | |||||||
|                 <el-input size="small" :maxlength="30" placeholder="请输入大屏项目名称" v-model="form.name"></el-input> |                 <el-input size="small" :maxlength="30" placeholder="请输入大屏项目名称" v-model="form.name"></el-input> | ||||||
|               </el-form-item> |               </el-form-item> | ||||||
|               <el-form-item label="描述" style="width: 100%;" prop="description"> |               <el-form-item label="描述" style="width: 100%;" prop="description"> | ||||||
|                 <el-input size="small" :maxlength="200" :rows="5" type="textarea" style="width: 100%;" placeholder="请输入描述" v-model="form.description"></el-input> |                 <el-input size="small" :maxlength="200" :rows="5" type="textarea" style="width: 100%;" placeholder="请输入描述" | ||||||
|  |                           v-model="form.description"></el-input> | ||||||
|               </el-form-item> |               </el-form-item> | ||||||
|               <el-form-item label="是否开启" style="width: 100%;" prop="status"> |               <el-form-item label="是否开启" style="width: 100%;" prop="status"> | ||||||
|                 <el-switch |                 <el-switch | ||||||
|                   v-model="form.status" |                     v-model="form.status" | ||||||
|                   active-value="1" |                     active-value="1" | ||||||
|                   inactive-value="0"> |                     inactive-value="0"> | ||||||
|                 </el-switch> |                 </el-switch> | ||||||
|               </el-form-item> |               </el-form-item> | ||||||
|             </div> |             </div> | ||||||
| @@ -31,20 +32,20 @@ | |||||||
|           </template> |           </template> | ||||||
|           <template #content> |           <template #content> | ||||||
|             <ai-table |             <ai-table | ||||||
|               :tableData="tableData" |                 :tableData="tableData" | ||||||
|               :col-configs="colConfigs" |                 :col-configs="colConfigs" | ||||||
|               :total="total" |                 :total="total" | ||||||
|               style="margin-top: 6px;" |                 style="margin-top: 6px;" | ||||||
|               :border="true" |                 :border="true" | ||||||
|               row-key="id" |                 row-key="id" | ||||||
|               :isShowPagination="false" |                 :isShowPagination="false" | ||||||
|               @getList="() => {}"> |                 @getList="() => {}"> | ||||||
|               <el-table-column slot="options" label="状态" align="center"> |               <el-table-column slot="options" label="状态" align="center"> | ||||||
|                 <template slot-scope="{ row }"> |                 <template slot-scope="{ row }"> | ||||||
|                   <el-switch |                   <el-switch | ||||||
|                     v-model="row.status" |                       v-model="row.status" | ||||||
|                     active-value="1" |                       active-value="1" | ||||||
|                     @change="() => onStatusChange(row.id)"> |                       @change="() => onStatusChange(row.id)"> | ||||||
|                   </el-switch> |                   </el-switch> | ||||||
|                 </template> |                 </template> | ||||||
|               </el-table-column> |               </el-table-column> | ||||||
| @@ -62,14 +63,14 @@ | |||||||
|         </ai-card> |         </ai-card> | ||||||
|       </el-form> |       </el-form> | ||||||
|       <Layout |       <Layout | ||||||
|         v-if="isShowLayout" |           v-if="isShowLayout" | ||||||
|         :instance="instance" |           :instance="instance" | ||||||
|         :dict="dict" |           :dict="dict" | ||||||
|         :params="query" |           :params="query" | ||||||
|         @change="onChange" |           @change="onChange" | ||||||
|         :urlPrefix="urlPrefix" |           :urlPrefix="urlPrefix" | ||||||
|         :theme="config.theme" |           :theme="config.theme" | ||||||
|         @close="isShowLayout = false"> |           @close="isShowLayout = false"> | ||||||
|       </Layout> |       </Layout> | ||||||
|       <ai-dialog :visible.sync="dialog" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV"> |       <ai-dialog :visible.sync="dialog" title="定制大屏" @closed="custom={}" @onConfirm="handleCustomizedDV"> | ||||||
|         <el-form ref="CustomDVFrom" size="small" :model="custom" :rules="rules" label-width="80px"> |         <el-form ref="CustomDVFrom" size="small" :model="custom" :rules="rules" label-width="80px"> | ||||||
| @@ -93,207 +94,207 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
|   import Layout from './Layout.vue' | import Layout from './Layout.vue' | ||||||
|   import Sortable from 'sortablejs' | import Sortable from 'sortablejs' | ||||||
|  |  | ||||||
|   export default { | export default { | ||||||
|     name: 'Add', |   name: 'Add', | ||||||
|     props: { |   props: { | ||||||
|       instance: Function, |     instance: Function, | ||||||
|       dict: Object, |     dict: Object, | ||||||
|       urlPrefix: String |     urlPrefix: String | ||||||
|     }, |   }, | ||||||
|     inject: { |   inject: { | ||||||
|       home: {default: ''} |     home: {default: ''} | ||||||
|     }, |   }, | ||||||
|     components: { |   components: { | ||||||
|       Layout |     Layout | ||||||
|     }, |   }, | ||||||
|  |  | ||||||
|     data() { |   data() { | ||||||
|       return { |     return { | ||||||
|         info: {}, |       info: {}, | ||||||
|         department: [], |       department: [], | ||||||
|         form: { |       form: { | ||||||
|           name: '', |         name: '', | ||||||
|           relationLsIds: '', |         relationLsIds: '', | ||||||
|           relationLsNames: '', |         relationLsNames: '', | ||||||
|           status: '1', |         status: '1', | ||||||
|           description: '' |         description: '' | ||||||
|         }, |  | ||||||
|         screenId: '', |  | ||||||
|         query: {}, |  | ||||||
|         total: 0, |  | ||||||
|         colConfigs: [ |  | ||||||
|           {prop: 'title', label: '标题'}, |  | ||||||
|           {prop: 'id', label: 'ID'} |  | ||||||
|         ], |  | ||||||
|         tableData: [], |  | ||||||
|         isShowLayout: false, |  | ||||||
|         id: '', |  | ||||||
|         dialog: false, |  | ||||||
|         custom: {}, |  | ||||||
|         rules: { |  | ||||||
|           dv: [{required: true, message: "请选择 定制大屏"}], |  | ||||||
|           title: [{required: true, message: "请输入 大屏标题"}], |  | ||||||
|         }, |  | ||||||
|         config: { |  | ||||||
|           backgroundImage: [] |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     }, |  | ||||||
|  |  | ||||||
|     created() { |  | ||||||
|       this.dict.load('customizedDVs') |  | ||||||
|       this.getInfo() |  | ||||||
|     }, |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     methods: { |  | ||||||
|       getInfo() { |  | ||||||
|         let {id} = this.$route.query |  | ||||||
|         this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenProjectDetailById?id=${id}`).then(res => { |  | ||||||
|           if (res?.data) { |  | ||||||
|             this.form = { |  | ||||||
|               ...res.data |  | ||||||
|             } |  | ||||||
|             if (res.data.relationLsIds) { |  | ||||||
|               this.tableData = res.data.lsList.map(v => { |  | ||||||
|                 let conf = JSON.parse(v.config || '') || {} |  | ||||||
|                 return { |  | ||||||
|                   id: v.id, |  | ||||||
|                   title: v.title, |  | ||||||
|                   dv: conf.custom || '', |  | ||||||
|                   meta: JSON.stringify(conf.meta), |  | ||||||
|                   isCustom: !!conf.custom, |  | ||||||
|                   status: v.status |  | ||||||
|                 } |  | ||||||
|               }) |  | ||||||
|               this.total = res.data.lsList.length |  | ||||||
|  |  | ||||||
|               this.$nextTick(() => { |  | ||||||
|                 this.rowDrop() |  | ||||||
|               }) |  | ||||||
|             } |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       }, |       }, | ||||||
|  |       screenId: '', | ||||||
|       onStatusChange (id) { |       query: {}, | ||||||
|         this.instance.post(`${this.urlPrefix}/appdiylargescreen/enableLargeScreen?id=${id}`).then(res => { |       total: 0, | ||||||
|           if (res.code === 0) { |       colConfigs: [ | ||||||
|             this.getInfo() |         {prop: 'title', label: '标题'}, | ||||||
|             this.$message.success('操作成功') |         {prop: 'id', label: 'ID'} | ||||||
|           } |       ], | ||||||
|         }) |       tableData: [], | ||||||
|  |       isShowLayout: false, | ||||||
|  |       id: '', | ||||||
|  |       dialog: false, | ||||||
|  |       custom: {}, | ||||||
|  |       rules: { | ||||||
|  |         dv: [{required: true, message: "请选择 定制大屏"}], | ||||||
|  |         title: [{required: true, message: "请输入 大屏标题"}], | ||||||
|       }, |       }, | ||||||
|  |       config: { | ||||||
|       rowDrop() { |         backgroundImage: [] | ||||||
|         const tbody = document.querySelector('.el-table__body-wrapper tbody') |  | ||||||
|         const _this = this |  | ||||||
|         Sortable.create(tbody, { |  | ||||||
|           onEnd({newIndex, oldIndex}) { |  | ||||||
|             const currRow = _this.tableData.splice(oldIndex, 1)[0] |  | ||||||
|             _this.tableData.splice(newIndex, 0, currRow) |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       toViewer(id) { |  | ||||||
|         this.$router.push({query: {id}, hash: "#preview"}) |  | ||||||
|       }, |  | ||||||
|       onChange(e) { |  | ||||||
|         const ids = this.tableData.map(v => v.id) |  | ||||||
|         if (ids.indexOf(e.id) < 0) { |  | ||||||
|           this.tableData.push({ |  | ||||||
|             title: e.title, |  | ||||||
|             id: e.id |  | ||||||
|           }) |  | ||||||
|         } else { |  | ||||||
|           const index = this.tableData.findIndex(v => v.id === e.id) |  | ||||||
|           this.$set(this.tableData[index], 'title', e.title) |  | ||||||
|         } |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       add() { |  | ||||||
|         this.query = { |  | ||||||
|           id: '', |  | ||||||
|           name: this.form.name |  | ||||||
|         } |  | ||||||
|         this.isShowLayout = true |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       toEdit(id, isCustom, form) { |  | ||||||
|         if (!isCustom) { |  | ||||||
|           this.query = { |  | ||||||
|             id, |  | ||||||
|             name: this.form.name |  | ||||||
|           } |  | ||||||
|  |  | ||||||
|           this.isShowLayout = true |  | ||||||
|         } else { |  | ||||||
|           this.dialog = true |  | ||||||
|           this.custom = { |  | ||||||
|             ...form, |  | ||||||
|  |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       remove(index) { |  | ||||||
|         this.tableData.splice(index, 1) |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       confirm() { |  | ||||||
|         this.$refs.form.validate((valid) => { |  | ||||||
|           if (valid) { |  | ||||||
|             const ids = this.tableData.map(v => v.id).join(',') |  | ||||||
|             const names = this.tableData.map(v => v.name).join(',') |  | ||||||
|             this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, { |  | ||||||
|               ...this.form, |  | ||||||
|               relationLsIds: ids, |  | ||||||
|               relationLsNames: names |  | ||||||
|             }).then(res => { |  | ||||||
|               if (res.code == 0) { |  | ||||||
|                 this.$message.success('提交成功') |  | ||||||
|  |  | ||||||
|                 this.home && this.home.refreshDvOptions && this.home.refreshDvOptions() |  | ||||||
|                 setTimeout(() => { |  | ||||||
|                   this.cancel() |  | ||||||
|                 }, 600) |  | ||||||
|               } |  | ||||||
|             }) |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       cancel() { |  | ||||||
|         this.$router.push({}) |  | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       handleCustomizedDV() { |  | ||||||
|         this.$refs.CustomDVFrom.validate(v => { |  | ||||||
|           if (v) { |  | ||||||
|             this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreen`, { |  | ||||||
|               config: JSON.stringify({ |  | ||||||
|                 custom: this.custom.dv, |  | ||||||
|                 meta: JSON.parse(this.custom.meta?.replace(/\\n/g, '') || null) |  | ||||||
|               }), |  | ||||||
|               status: 1, |  | ||||||
|               id: this.custom.id, |  | ||||||
|               title: this.custom.title, |  | ||||||
|             }).then(res => { |  | ||||||
|               if (res?.code == 0 && res?.data) { |  | ||||||
|                 this.$message.success('保存成功') |  | ||||||
|                 this.onChange(res.data) |  | ||||||
|                 this.dialog = false |  | ||||||
|               } |  | ||||||
|             }) |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   created() { | ||||||
|  |     this.dict.load('customizedDVs') | ||||||
|  |     this.getInfo() | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     getInfo() { | ||||||
|  |       let {id} = this.$route.query | ||||||
|  |       id && this.instance.post(`${this.urlPrefix}/appdiylargescreen/queryLargeScreenProjectDetailById?id=${id}`).then(res => { | ||||||
|  |         if (res?.data) { | ||||||
|  |           this.form = { | ||||||
|  |             ...res.data | ||||||
|  |           } | ||||||
|  |           if (res.data.relationLsIds) { | ||||||
|  |             this.tableData = res.data.lsList.map(v => { | ||||||
|  |               let conf = JSON.parse(v.config || '') || {} | ||||||
|  |               return { | ||||||
|  |                 id: v.id, | ||||||
|  |                 title: v.title, | ||||||
|  |                 dv: conf.custom || '', | ||||||
|  |                 meta: JSON.stringify(conf.meta), | ||||||
|  |                 isCustom: !!conf.custom, | ||||||
|  |                 status: v.status | ||||||
|  |               } | ||||||
|  |             }) | ||||||
|  |             this.total = res.data.lsList.length | ||||||
|  |  | ||||||
|  |             this.$nextTick(() => { | ||||||
|  |               this.rowDrop() | ||||||
|  |             }) | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     onStatusChange(id) { | ||||||
|  |       id && this.instance.post(`${this.urlPrefix}/appdiylargescreen/enableLargeScreen?id=${id}`).then(res => { | ||||||
|  |         if (res.code === 0) { | ||||||
|  |           this.getInfo() | ||||||
|  |           this.$message.success('操作成功') | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     rowDrop() { | ||||||
|  |       const tbody = document.querySelector('.el-table__body-wrapper tbody') | ||||||
|  |       const _this = this | ||||||
|  |       Sortable.create(tbody, { | ||||||
|  |         onEnd({newIndex, oldIndex}) { | ||||||
|  |           const currRow = _this.tableData.splice(oldIndex, 1)[0] | ||||||
|  |           _this.tableData.splice(newIndex, 0, currRow) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     toViewer(id) { | ||||||
|  |       this.$router.push({query: {id}, hash: "#preview"}) | ||||||
|  |     }, | ||||||
|  |     onChange(e) { | ||||||
|  |       const ids = this.tableData.map(v => v.id) | ||||||
|  |       if (ids.indexOf(e.id) < 0) { | ||||||
|  |         this.tableData.push({ | ||||||
|  |           title: e.title, | ||||||
|  |           id: e.id | ||||||
|  |         }) | ||||||
|  |       } else { | ||||||
|  |         const index = this.tableData.findIndex(v => v.id === e.id) | ||||||
|  |         this.$set(this.tableData[index], 'title', e.title) | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     add() { | ||||||
|  |       this.query = { | ||||||
|  |         id: '', | ||||||
|  |         name: this.form.name | ||||||
|  |       } | ||||||
|  |       this.isShowLayout = true | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     toEdit(id, isCustom, form) { | ||||||
|  |       if (!isCustom) { | ||||||
|  |         this.query = { | ||||||
|  |           id, | ||||||
|  |           name: this.form.name | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.isShowLayout = true | ||||||
|  |       } else { | ||||||
|  |         this.dialog = true | ||||||
|  |         this.custom = { | ||||||
|  |           ...form, | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     remove(index) { | ||||||
|  |       this.tableData.splice(index, 1) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     confirm() { | ||||||
|  |       this.$refs.form.validate((valid) => { | ||||||
|  |         if (valid) { | ||||||
|  |           const ids = this.tableData.map(v => v.id).join(',') | ||||||
|  |           const names = this.tableData.map(v => v.name).join(',') | ||||||
|  |           this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreenProject`, { | ||||||
|  |             ...this.form, | ||||||
|  |             relationLsIds: ids, | ||||||
|  |             relationLsNames: names | ||||||
|  |           }).then(res => { | ||||||
|  |             if (res.code == 0) { | ||||||
|  |               this.$message.success('提交成功') | ||||||
|  |  | ||||||
|  |               this.home && this.home.refreshDvOptions && this.home.refreshDvOptions() | ||||||
|  |               setTimeout(() => { | ||||||
|  |                 this.cancel() | ||||||
|  |               }, 600) | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     cancel() { | ||||||
|  |       this.$router.push({}) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     handleCustomizedDV() { | ||||||
|  |       this.$refs.CustomDVFrom.validate(v => { | ||||||
|  |         if (v) { | ||||||
|  |           this.instance.post(`${this.urlPrefix}/appdiylargescreen/addOrUpdateLargeScreen`, { | ||||||
|  |             config: JSON.stringify({ | ||||||
|  |               custom: this.custom.dv, | ||||||
|  |               meta: JSON.parse(this.custom.meta?.replace(/\\n/g, '') || null) | ||||||
|  |             }), | ||||||
|  |             status: 1, | ||||||
|  |             id: this.custom.id, | ||||||
|  |             title: this.custom.title, | ||||||
|  |           }).then(res => { | ||||||
|  |             if (res?.code == 0 && res?.data) { | ||||||
|  |               this.$message.success('保存成功') | ||||||
|  |               this.onChange(res.data) | ||||||
|  |               this.dialog = false | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style scoped lang="scss"> | <style scoped lang="scss"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user