|
|
@@ -12,7 +12,7 @@
|
|
|
<el-form-item label="模板编码:" prop="code">
|
|
|
<el-input
|
|
|
clearable
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.code"
|
|
|
placeholder="请输入"
|
|
|
/>
|
|
|
@@ -20,7 +20,7 @@
|
|
|
<el-form-item label="模板名称:" prop="name">
|
|
|
<el-input
|
|
|
clearable
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.name"
|
|
|
placeholder="请输入"
|
|
|
/>
|
|
|
@@ -28,14 +28,14 @@
|
|
|
<el-form-item label="默认发送人:" prop="nickname">
|
|
|
<el-input
|
|
|
clearable
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model.number="formData.nickname"
|
|
|
placeholder="请输入排序"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="接收人类型:" prop="recipientType">
|
|
|
<el-select
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.recipientType"
|
|
|
placeholder="请选择接收人类型"
|
|
|
@change="handleRecipientTypeChange"
|
|
|
@@ -48,12 +48,19 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="formData.recipientType != 0" label="接收人:" prop="recipient">
|
|
|
- <role-select v-if="formData.recipientType == 2" v-model="formData.recipient" />
|
|
|
+ <el-form-item
|
|
|
+ v-if="formData.recipientType != 0"
|
|
|
+ label="接收人:"
|
|
|
+ prop="recipient"
|
|
|
+ >
|
|
|
+ <role-select
|
|
|
+ v-if="formData.recipientType == 2"
|
|
|
+ v-model="formData.recipient"
|
|
|
+ />
|
|
|
<el-input
|
|
|
v-if="formData.recipientType == 1"
|
|
|
clearable
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.recipientName"
|
|
|
placeholder="请选择"
|
|
|
@click.native="handleRecipientClick"
|
|
|
@@ -63,30 +70,40 @@
|
|
|
<el-input
|
|
|
clearable
|
|
|
type="textarea"
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.content"
|
|
|
placeholder="请输入"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="状态:" prop="status">
|
|
|
- <el-radio :disabled="dialogType=='view'" v-model="formData.status" :label="1">启用</el-radio>
|
|
|
- <el-radio :disabled="dialogType=='view'" v-model="formData.status" :label="0">禁用</el-radio>
|
|
|
+ <el-radio
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
+ v-model="formData.status"
|
|
|
+ :label="1"
|
|
|
+ >启用</el-radio
|
|
|
+ >
|
|
|
+ <el-radio
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
+ v-model="formData.status"
|
|
|
+ :label="0"
|
|
|
+ >禁用</el-radio
|
|
|
+ >
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="备注:" prop="remark">
|
|
|
<el-input
|
|
|
clearable
|
|
|
type="textarea"
|
|
|
- :disabled="dialogType=='view'"
|
|
|
+ :disabled="dialogType == 'view'"
|
|
|
v-model="formData.remark"
|
|
|
placeholder="请输入"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
-
|
|
|
</el-form>
|
|
|
<template v-slot:footer>
|
|
|
- <el-button type="primary" :loading="loading" @click="save">确认</el-button>
|
|
|
+ <el-button type="primary" :loading="loading" @click="save"
|
|
|
+ >确认</el-button
|
|
|
+ >
|
|
|
<el-button @click="closeDialog">返回</el-button>
|
|
|
</template>
|
|
|
<staffSelection
|
|
|
@@ -97,61 +114,62 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import dictMixins from '@/mixins/dictMixins';
|
|
|
-import {notifyTemplateGetByIdAPI, notifyTemplateSaveAPI, notifyTemplateUpdateAPI} from "@/api/notifyManage";
|
|
|
-import RoleSelect from '@/views/system/user/components/role-select.vue';
|
|
|
-import staffSelection from '@/views/enterpriseModel/dept/components/staffSelection.vue';
|
|
|
-export default {
|
|
|
- name: 'addOrEditDialog',
|
|
|
- props: {
|
|
|
- addOrEditDialogFlag: [Boolean],
|
|
|
- },
|
|
|
- components: {
|
|
|
- RoleSelect,
|
|
|
- staffSelection
|
|
|
- },
|
|
|
- mixins: [dictMixins],
|
|
|
- data() {
|
|
|
-
|
|
|
- return {
|
|
|
- recipientTypeOptions: [
|
|
|
- {
|
|
|
- value: 0,
|
|
|
- label: '业务自定义'
|
|
|
- },
|
|
|
- {
|
|
|
- value: 1,
|
|
|
- label: '指定人'
|
|
|
- },
|
|
|
- {
|
|
|
- value: 2,
|
|
|
- label: '指定角色'
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
+ import {
|
|
|
+ notifyTemplateGetByIdAPI,
|
|
|
+ notifyTemplateSaveAPI,
|
|
|
+ notifyTemplateUpdateAPI
|
|
|
+ } from '@/api/notifyManage';
|
|
|
+ import RoleSelect from '@/views/system/user/components/role-select.vue';
|
|
|
+ import staffSelection from '@/views/enterpriseModel/dept/components/staffSelection.vue';
|
|
|
+ export default {
|
|
|
+ name: 'addOrEditDialog',
|
|
|
+ props: {
|
|
|
+ addOrEditDialogFlag: [Boolean]
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ RoleSelect,
|
|
|
+ staffSelection
|
|
|
+ },
|
|
|
+ mixins: [dictMixins],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ recipientTypeOptions: [
|
|
|
+ {
|
|
|
+ value: 0,
|
|
|
+ label: '业务自定义'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: '指定人'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 2,
|
|
|
+ label: '指定角色'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ users: [],
|
|
|
+ // 表单数据
|
|
|
+ formData: {
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ nickname: '',
|
|
|
+ content: '',
|
|
|
+ status: 1,
|
|
|
+ remark: '',
|
|
|
+ recipientType: 0,
|
|
|
+ recipient: [],
|
|
|
+ recipientName: ''
|
|
|
},
|
|
|
- ],
|
|
|
- users: [],
|
|
|
- // 表单数据
|
|
|
- formData: {
|
|
|
- code: '',
|
|
|
- name: '',
|
|
|
- nickname: '',
|
|
|
- content: '',
|
|
|
- status: 1,
|
|
|
- remark: '',
|
|
|
- recipientType: 0,
|
|
|
- recipient: [],
|
|
|
- recipientName: ''
|
|
|
- },
|
|
|
- title: null,
|
|
|
-
|
|
|
+ title: null,
|
|
|
|
|
|
-
|
|
|
- dialogType: '',
|
|
|
- // 提交状态
|
|
|
- loading: false,
|
|
|
- };
|
|
|
- },
|
|
|
- computed: {
|
|
|
- // 表单验证规则
|
|
|
+ dialogType: '',
|
|
|
+ // 提交状态
|
|
|
+ loading: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 表单验证规则
|
|
|
rules() {
|
|
|
return {
|
|
|
name: [
|
|
|
@@ -202,68 +220,74 @@ export default {
|
|
|
message: '请选择接收人',
|
|
|
trigger: 'change'
|
|
|
}
|
|
|
- ],
|
|
|
- }
|
|
|
+ ]
|
|
|
+ };
|
|
|
}
|
|
|
- },
|
|
|
- created() {
|
|
|
- },
|
|
|
- methods: {
|
|
|
- handleRecipientTypeChange() {
|
|
|
- this.formData.recipient = [];
|
|
|
- this.formData.recipientName = '';
|
|
|
},
|
|
|
- handleRecipientClick() {
|
|
|
- this.$refs.staffSelection.open(
|
|
|
+ created() {},
|
|
|
+ methods: {
|
|
|
+ handleRecipientTypeChange() {
|
|
|
+ this.formData.recipient = [];
|
|
|
+ this.formData.recipientName = '';
|
|
|
+ },
|
|
|
+ handleRecipientClick() {
|
|
|
+ console.log(this.formData.recipient, 'this.formData.recipient');
|
|
|
+ this.$refs.staffSelection.open(
|
|
|
JSON.parse(JSON.stringify(this.formData.recipient))
|
|
|
);
|
|
|
- },
|
|
|
-
|
|
|
- confirmStaffSelection(data) {
|
|
|
- console.log(data);
|
|
|
- this.formData.recipient = data.map(item => {
|
|
|
+ },
|
|
|
+
|
|
|
+ confirmStaffSelection(data) {
|
|
|
+ console.log(data);
|
|
|
+ this.formData.recipient = data.map((item) => {
|
|
|
return {
|
|
|
...item,
|
|
|
recipientId: item.id,
|
|
|
recipientName: item.name,
|
|
|
type: this.formData.recipientType
|
|
|
- }
|
|
|
+ };
|
|
|
});
|
|
|
- this.formData.recipientName = data.map(item => item.name).join(',');
|
|
|
+ this.formData.recipientName = data.map((item) => item.name).join(',');
|
|
|
},
|
|
|
- init(type, row = {}) {
|
|
|
- this.title = type == 'add' ? '新增' : '修改'
|
|
|
- this.dialogType = type
|
|
|
- if (type !== 'add') {
|
|
|
- this.getNotifyTemplateInfo(row)
|
|
|
- }
|
|
|
- },
|
|
|
- async getNotifyTemplateInfo(row) {
|
|
|
- this.formData = await notifyTemplateGetByIdAPI(row.id)
|
|
|
- },
|
|
|
- /* 保存编辑 */
|
|
|
- save() {
|
|
|
- this.$refs.formRef.validate(async (valid) => {
|
|
|
- if (!valid) return this.$message.warning('有必填项未填写,请检查');
|
|
|
- this.loading = true;
|
|
|
-
|
|
|
- const params = {...this.formData};
|
|
|
- const API = this.dialogType == 'add' ? notifyTemplateSaveAPI : notifyTemplateUpdateAPI
|
|
|
- try {
|
|
|
- await API(params)
|
|
|
- this.$message.success('操作成功')
|
|
|
- this.$emit('done')
|
|
|
- this.closeDialog()
|
|
|
- } catch (e) {
|
|
|
- this.loading = false;
|
|
|
+ init(type, row = {}) {
|
|
|
+ this.title = type == 'add' ? '新增' : '修改';
|
|
|
+ this.dialogType = type;
|
|
|
+ if (type !== 'add') {
|
|
|
+ this.getNotifyTemplateInfo(row);
|
|
|
}
|
|
|
+ },
|
|
|
+ async getNotifyTemplateInfo(row) {
|
|
|
+ this.formData = await notifyTemplateGetByIdAPI(row.id);
|
|
|
|
|
|
- });
|
|
|
- },
|
|
|
- /* 关闭弹窗 */
|
|
|
- closeDialog() {
|
|
|
- this.$emit('update:addOrEditDialogFlag', false)
|
|
|
+ this.formData.recipientName = this.formData.recipient
|
|
|
+ .map((item) => item.recipientName)
|
|
|
+ .join(',');
|
|
|
+ },
|
|
|
+ /* 保存编辑 */
|
|
|
+ save() {
|
|
|
+ this.$refs.formRef.validate(async (valid) => {
|
|
|
+ if (!valid) return this.$message.warning('有必填项未填写,请检查');
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ const params = { ...this.formData };
|
|
|
+ const API =
|
|
|
+ this.dialogType == 'add'
|
|
|
+ ? notifyTemplateSaveAPI
|
|
|
+ : notifyTemplateUpdateAPI;
|
|
|
+ try {
|
|
|
+ await API(params);
|
|
|
+ this.$message.success('操作成功');
|
|
|
+ this.$emit('done');
|
|
|
+ this.closeDialog();
|
|
|
+ } catch (e) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 关闭弹窗 */
|
|
|
+ closeDialog() {
|
|
|
+ this.$emit('update:addOrEditDialogFlag', false);
|
|
|
+ }
|
|
|
}
|
|
|
- },
|
|
|
-};
|
|
|
+ };
|
|
|
</script>
|