| | |
| | | <template> |
| | | <el-dialog |
| | | :title="row?'修改公告':'新增公告'" |
| | | :close-on-click-modal="false" |
| | | :visible.sync="visible" |
| | | @close = 'handClose' |
| | | > |
| | | <el-form |
| | | :model="dataForm" |
| | | :rules="dataRule" |
| | | ref="dataForm" |
| | | @keyup.enter.native="dataFormSubmit()" |
| | | label-width="120px" |
| | | > |
| | | <el-dialog :title="row ? '修改公告' : '新增公告'" :close-on-click-modal="false" :visible.sync="visible" @close='handClose'> |
| | | <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" |
| | | label-width="120px"> |
| | | <el-form-item label="标题" prop="title"> |
| | | <el-input v-model="dataForm.title" placeholder="标题"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="登录人资金密码" prop="loginSafeword"> |
| | | <!-- <el-form-item label="登录人资金密码" prop="loginSafeword"> |
| | | <el-input v-model="dataForm.loginSafeword" type="password" placeholder="登录人资金密码"></el-input> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <el-form-item label="业务代码" prop="contentCode"> |
| | | <el-input |
| | | v-model="dataForm.contentCode" |
| | | placeholder="业务代码" |
| | | ></el-input> |
| | | <el-input v-model="dataForm.contentCode" placeholder="业务代码"></el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="语言"> |
| | | <el-select |
| | | v-model="langug.value" |
| | | placeholder="请选择" |
| | | @change="changeVal()" |
| | | > |
| | | <el-option |
| | | v-for="item in langug" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | <el-select v-model="langug.value" placeholder="请选择" @change="changeVal()"> |
| | | <el-option v-for="item in langug" :key="item.value" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="模块"> |
| | | <el-select |
| | | v-model="options.value" |
| | | placeholder="请选择" |
| | | @change="changeVal()" |
| | | > |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | <el-select v-model="options.value" placeholder="请选择" @change="changeVal()"> |
| | | <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="内容" prop=""> |
| | | <el-input |
| | | type="textarea" |
| | | placeholder="请输入内容" |
| | | v-model="dataForm.content" |
| | | :autosize="{ minRows: 8, maxRows: 8 }" |
| | | show-word-limit |
| | | > |
| | | <el-input type="textarea" placeholder="请输入内容" v-model="dataForm.content" :autosize="{ minRows: 8, maxRows: 8 }" |
| | | show-word-limit> |
| | | </el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | label: "name", |
| | | children: "children", |
| | | }, |
| | | row:'', |
| | | row: '', |
| | | options: [], // 模块 |
| | | langug: [], // 语言 |
| | | dataForm: { |
| | |
| | | content: "", |
| | | contentCode: "", |
| | | id: "", |
| | | loginSafeword: "", |
| | | // loginSafeword: "", |
| | | title: "", |
| | | }, |
| | | dataRule: { |
| | | |
| | | title:[ |
| | | |
| | | title: [ |
| | | { required: true, message: "标题不能为空", trigger: "blur" }, |
| | | ], |
| | | loginSafeword:[ |
| | | { required: true, message: "登录人资金密码不能为空", trigger: "blur" }, |
| | | ], |
| | | contentCode:[ |
| | | // loginSafeword: [ |
| | | // { required: true, message: "登录人资金密码不能为空", trigger: "blur" }, |
| | | // ], |
| | | contentCode: [ |
| | | { required: true, message: "业务代码不能为空", trigger: "blur" }, |
| | | ], |
| | | content:[ |
| | | content: [ |
| | | { required: true, message: "内容不能为空", trigger: "blur" }, |
| | | ], |
| | | roleName: [ |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | init(arr,arr2, row) { |
| | | init(arr, arr2, row) { |
| | | this.langug = arr; |
| | | this.options = arr2 |
| | | this.row = row || '' |
| | | if (row) { |
| | | this.dataForm.title = row.title |
| | | this.options.value = row.model |
| | | this.langug.value = row.language |
| | | this.dataForm.content = row.content |
| | | this.dataForm.contentCode = row.contentCode |
| | | this.dataForm.id = row.uuid |
| | | }else{ |
| | | this.options.value = this.options[0].value |
| | | this.options.value = row.model |
| | | this.langug.value = row.language |
| | | this.dataForm.content = row.content |
| | | this.dataForm.contentCode = row.contentCode |
| | | this.dataForm.id = row.uuid |
| | | } else { |
| | | this.options.value = this.options[0].value |
| | | this.langug.value = this.langug[0].value |
| | | } |
| | | this.visible = true; |
| | |
| | | changeVal(val) { |
| | | this.$forceUpdate(); |
| | | }, |
| | | handClose(){ |
| | | this.$data.dataForm=JSON.parse(JSON.stringify(this.$options.data().dataForm)) |
| | | this.$nextTick(() => { |
| | | this.$refs['dataForm'].clearValidate() // 清除表单验证 |
| | | }) |
| | | this.langug.value = '' |
| | | this.options.value = '' |
| | | }, |
| | | handClose() { |
| | | this.$data.dataForm = JSON.parse(JSON.stringify(this.$options.data().dataForm)) |
| | | this.$nextTick(() => { |
| | | this.$refs['dataForm'].clearValidate() // 清除表单验证 |
| | | }) |
| | | this.langug.value = '' |
| | | this.options.value = '' |
| | | }, |
| | | // 表单提交 |
| | | dataFormSubmit: Debounce(function () { |
| | | if (this.row) { |
| | | this.$refs["dataForm"].validate((valid) => { |
| | | if (valid) { |
| | | this.$http({ |
| | | // 修改 |
| | | url: this.$http.adornUrl(`/cms/update`), |
| | | method: "post", |
| | | data: this.$http.adornData({ |
| | | content: this.dataForm.content, |
| | | contentCode: this.dataForm.contentCode, |
| | | language: this.langug.value, |
| | | loginSafeword: encrypt(this.dataForm.loginSafeword), |
| | | model: this.options.value, |
| | | title: this.dataForm.title, |
| | | id: this.dataForm.id, |
| | | }), |
| | | }).then(({ data }) => { |
| | | if (data.code == 0) { |
| | | this.$message({ |
| | | message: "操作成功", |
| | | type: "success", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.visible = false; |
| | | this.$emit("refreshDataList"); |
| | | }, |
| | | }); |
| | | } else { |
| | | this.$message({ |
| | | message: data.msg, |
| | | type: "error", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | |
| | | }, |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | this.$refs["dataForm"].validate((valid) => { |
| | | if (valid) { |
| | | this.$http({ |
| | | // 修改 |
| | | url: this.$http.adornUrl(`/cms/update`), |
| | | method: "post", |
| | | data: this.$http.adornData({ |
| | | content: this.dataForm.content, |
| | | contentCode: this.dataForm.contentCode, |
| | | language: this.langug.value, |
| | | // loginSafeword: encrypt(this.dataForm.loginSafeword), |
| | | model: this.options.value, |
| | | title: this.dataForm.title, |
| | | id: this.dataForm.id, |
| | | }), |
| | | }).then(({ data }) => { |
| | | if (data.code == 0) { |
| | | this.$message({ |
| | | message: "操作成功", |
| | | type: "success", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.visible = false; |
| | | this.$emit("refreshDataList"); |
| | | }, |
| | | }); |
| | | } else { |
| | | this.$message({ |
| | | message: data.msg, |
| | | type: "error", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | |
| | | }, |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | this.$refs["dataForm"].validate((valid) => { |
| | | if (valid) { |
| | | this.$http({ |
| | | // 新增 |
| | | url: this.$http.adornUrl(`/cms/add`), |
| | | method: "post", |
| | | data: this.$http.adornData({ |
| | | content: this.dataForm.content, |
| | | contentCode: this.dataForm.contentCode, |
| | | language: this.langug.value, |
| | | loginSafeword: encrypt(this.dataForm.loginSafeword), |
| | | model: this.options.value, |
| | | title: this.dataForm.title, |
| | | }), |
| | | }).then(({ data }) => { |
| | | if (data.code == 0) { |
| | | this.$message({ |
| | | message: "操作成功", |
| | | type: "success", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.visible = false; |
| | | this.$emit("refreshDataList"); |
| | | }, |
| | | }); |
| | | } else { |
| | | this.$message({ |
| | | message: data.msg, |
| | | type: "error", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | |
| | | }, |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | this.$refs["dataForm"].validate((valid) => { |
| | | if (valid) { |
| | | this.$http({ |
| | | // 新增 |
| | | url: this.$http.adornUrl(`/cms/add`), |
| | | method: "post", |
| | | data: this.$http.adornData({ |
| | | content: this.dataForm.content, |
| | | contentCode: this.dataForm.contentCode, |
| | | language: this.langug.value, |
| | | // loginSafeword: encrypt(this.dataForm.loginSafeword), |
| | | model: this.options.value, |
| | | title: this.dataForm.title, |
| | | }), |
| | | }).then(({ data }) => { |
| | | if (data.code == 0) { |
| | | this.$message({ |
| | | message: "操作成功", |
| | | type: "success", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | this.visible = false; |
| | | this.$emit("refreshDataList"); |
| | | }, |
| | | }); |
| | | } else { |
| | | this.$message({ |
| | | message: data.msg, |
| | | type: "error", |
| | | duration: 1500, |
| | | onClose: () => { |
| | | |
| | | }, |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }), |
| | | }, |