|
|
@@ -7,84 +7,77 @@
|
|
|
resizable
|
|
|
maxable
|
|
|
>
|
|
|
- <div v-loading="loading || saving">
|
|
|
+ <div class="switch" v-if="type == 'view'">
|
|
|
+ <div class="switch_left">
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ v-for="item in tabOptions"
|
|
|
+ :key="item.key"
|
|
|
+ :class="{ active: activeComp == item.key }"
|
|
|
+ @click="activeComp = item.key"
|
|
|
+ >
|
|
|
+ {{ item.name }}
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-show="activeComp == 'main'">
|
|
|
<div v-html="addForm.valueJson?.template"></div>
|
|
|
</div>
|
|
|
-
|
|
|
+ <bpmDetail
|
|
|
+ v-if="activeComp == 'bpm' && addForm.processInstanceId"
|
|
|
+ :id="addForm.processInstanceId"
|
|
|
+ ></bpmDetail>
|
|
|
<template v-slot:footer>
|
|
|
- <!-- <el-button
|
|
|
- type="primary"
|
|
|
- :loading="saving"
|
|
|
- :disabled="saving"
|
|
|
- @click="submit"
|
|
|
- >提 交</el-button
|
|
|
- > -->
|
|
|
- <el-button :disabled="saving" @click="handleClose">取 消</el-button>
|
|
|
+ <el-button @click="handleClose">取 消</el-button>
|
|
|
</template>
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import bpmDetail from '@/views/bpm/processInstance/businessDetail.vue';
|
|
|
+
|
|
|
import dictMixins from '@/mixins/dictMixins';
|
|
|
import {
|
|
|
getQmsReportTemplateById,
|
|
|
updateQmsReportTemplate,
|
|
|
saveQmsReportTemplate
|
|
|
} from '@/api/qmsreporttemplate/index';
|
|
|
-
|
|
|
+ const formBaseData = {
|
|
|
+ code: '',
|
|
|
+ id: null,
|
|
|
+ isEnabled: 0,
|
|
|
+ name: '',
|
|
|
+ remark: '',
|
|
|
+ type: 0,
|
|
|
+ isDefault: 0, // 是否启用(1:默认;0:否)
|
|
|
+ valueJson: '' // 模板内容
|
|
|
+ };
|
|
|
export default {
|
|
|
mixins: [dictMixins],
|
|
|
data() {
|
|
|
- const formBaseData = {
|
|
|
- code: '',
|
|
|
- id: null,
|
|
|
- isEnabled: 0,
|
|
|
- name: '',
|
|
|
- remark: '',
|
|
|
- type: 0,
|
|
|
- isDefault: 0, // 是否启用(1:默认;0:否)
|
|
|
- valueJson: '' // 模板内容
|
|
|
- };
|
|
|
-
|
|
|
return {
|
|
|
+ activeComp: 'main',
|
|
|
+ tabOptions: [
|
|
|
+ { key: 'main', name: '模板详情' },
|
|
|
+ { key: 'bpm', name: '流程详情' }
|
|
|
+ ],
|
|
|
visible: false,
|
|
|
type: 'add',
|
|
|
- title: '表单弹窗',
|
|
|
- formBaseData,
|
|
|
addForm: JSON.parse(JSON.stringify(formBaseData)),
|
|
|
- loading: false,
|
|
|
- saving: false,
|
|
|
- rules: {
|
|
|
- name: [
|
|
|
- { required: true, message: '请输入模板名称', trigger: 'blur' }
|
|
|
- ],
|
|
|
- code: [
|
|
|
- { required: true, message: '请输入模板编码', trigger: 'blur' },
|
|
|
- {
|
|
|
- min: 1,
|
|
|
- max: 50,
|
|
|
- message: '长度在 1 到 50 个字符',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ],
|
|
|
- remark: [
|
|
|
- { max: 200, message: '备注最多 200 个字符', trigger: 'blur' }
|
|
|
- ]
|
|
|
- }
|
|
|
+ loading: false
|
|
|
};
|
|
|
},
|
|
|
+ components: { bpmDetail },
|
|
|
methods: {
|
|
|
// 打开弹窗
|
|
|
open(type, data) {
|
|
|
this.type = type;
|
|
|
this.visible = true;
|
|
|
+ this.activeComp = 'main';
|
|
|
|
|
|
- if (type === 'add') {
|
|
|
- this.title = '新建模板';
|
|
|
- } else {
|
|
|
- this.title = '预览模板';
|
|
|
- this.getDetail(data.id);
|
|
|
- }
|
|
|
+ this.title = '预览模板';
|
|
|
+ this.getDetail(data.id);
|
|
|
},
|
|
|
// 获取详情
|
|
|
async getDetail(id) {
|
|
|
@@ -92,7 +85,7 @@
|
|
|
try {
|
|
|
const data = await getQmsReportTemplateById(id);
|
|
|
console.log('data', data);
|
|
|
- this.addForm = Object.assign({}, this.formBaseData, data || {});
|
|
|
+ this.addForm = Object.assign({}, formBaseData, data || {});
|
|
|
} catch (e) {
|
|
|
this.$message.error('获取模板详情失败');
|
|
|
} finally {
|
|
|
@@ -100,7 +93,7 @@
|
|
|
}
|
|
|
},
|
|
|
resetForm() {
|
|
|
- this.addForm = JSON.parse(JSON.stringify(this.formBaseData));
|
|
|
+ this.addForm = JSON.parse(JSON.stringify(formBaseData));
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.formRef && this.$refs.formRef.clearValidate();
|
|
|
});
|
|
|
@@ -109,29 +102,6 @@
|
|
|
handleClose() {
|
|
|
this.visible = false;
|
|
|
this.resetForm();
|
|
|
- },
|
|
|
- // 提交
|
|
|
- submit() {
|
|
|
- this.$refs.formRef.validate(async (valid) => {
|
|
|
- if (!valid) return;
|
|
|
- this.saving = true;
|
|
|
- try {
|
|
|
- const payload = { ...this.addForm };
|
|
|
- let res;
|
|
|
- if (this.type === 'add') {
|
|
|
- res = await saveQmsReportTemplate(payload);
|
|
|
- } else {
|
|
|
- res = await updateQmsReportTemplate(payload);
|
|
|
- }
|
|
|
- this.$message.success('保存成功');
|
|
|
- this.$emit('reload');
|
|
|
- this.handleClose();
|
|
|
- } catch (e) {
|
|
|
- this.$message.error(e?.message || '保存失败');
|
|
|
- } finally {
|
|
|
- this.saving = false;
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
};
|