|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <el-dialog v-model="visible" :title="titleMap[mode]" :width="680" @closed="$emit('closed', mode)">
|
|
|
+ <el-dialog v-model="visible" :title="titleMap[mode]" :width="680" @closed="$emit('closed')">
|
|
|
<el-form ref="formRef" :model="form" :rules="rules" :disabled="mode == 'detail' || mode == 'approve'" label-width="100px">
|
|
|
<el-row>
|
|
|
<el-col v-if="form.id" :span="12">
|
|
|
@@ -107,158 +107,132 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <approve-detail ref="approveRef" @closed="form_reset"></approve-detail>
|
|
|
+ <approve-detail v-if="dialog" ref="approveDetail" @success="setData" @closed="dialog = false"></approve-detail>
|
|
|
</template>
|
|
|
|
|
|
-<script setup>
|
|
|
-import API from "@/api/policy/share.js";
|
|
|
-import { useUserStore } from "@/store/user.js";
|
|
|
-import { policyShareDict } from "./main.js";
|
|
|
+<script>
|
|
|
+import API from "@/api/policy/share";
|
|
|
+import { useUserStore } from "@/store/user";
|
|
|
+import { levelDic, typeDic, inWHDic } from "./main";
|
|
|
import yhUpload from "@/components/Upload/index.vue";
|
|
|
import approveDetail from "./approve.vue";
|
|
|
|
|
|
-const $emit = defineEmits(["closed"]);
|
|
|
-const { userInfo } = storeToRefs(useUserStore()); // store 用户
|
|
|
-const { levelDic, typeDic, inWHDic } = policyShareDict();
|
|
|
-
|
|
|
-const visible = ref(false);
|
|
|
-const mode = ref("add");
|
|
|
-const titleMap = reactive({
|
|
|
- add: "新增政策",
|
|
|
- edit: "编辑政策",
|
|
|
- detail: "政策详情",
|
|
|
- approve: "政策详情"
|
|
|
-});
|
|
|
-
|
|
|
-let form = reactive({
|
|
|
- createId: userInfo.value.id,
|
|
|
- createName: userInfo.value.name,
|
|
|
- companyName: null,
|
|
|
- deptName: null,
|
|
|
- name: null,
|
|
|
- zcLevel: null,
|
|
|
- zcType: null,
|
|
|
- docNo: null,
|
|
|
- contactPhone: null,
|
|
|
- abstractContent: null,
|
|
|
- fileList: []
|
|
|
-});
|
|
|
-const rules = reactive({
|
|
|
- businessNo: [{ required: true }],
|
|
|
- name: [{ required: true, message: "请输入政策名称" }],
|
|
|
- zcLevel: [{ required: true, message: "请选择政策等级" }],
|
|
|
- zcType: [{ required: true, message: "请选择政策类别" }],
|
|
|
- docNo: [{ required: true, message: "请输入政策文号" }],
|
|
|
- contactPhone: [{ required: true, message: "请输入联系方式" }],
|
|
|
- abstractContent: [{ required: true, message: "请输入政策概要" }],
|
|
|
- score: [{ required: true, message: "请输入分值" }],
|
|
|
- isInWh: [{ required: true }],
|
|
|
- inWhType: [{ required: true, message: "请选择入库类型" }],
|
|
|
-});
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- API.getUserDept(userInfo.value.deptId).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- form.companyName = res.data.companyName;
|
|
|
- form.deptName = res.data.deptName;
|
|
|
- }
|
|
|
- });
|
|
|
-})
|
|
|
-
|
|
|
-const init = (modeValue = "add", data) => {
|
|
|
- mode.value = modeValue;
|
|
|
- visible.value = true;
|
|
|
-
|
|
|
- if (data) {
|
|
|
- form.updateId = userInfo.value.id;
|
|
|
- setData(data);
|
|
|
- }
|
|
|
-}
|
|
|
-const setData = id => {
|
|
|
- API.detail(id).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- const rowData = reactive({
|
|
|
+const { userInfo } = useUserStore(); // store 用户
|
|
|
+
|
|
|
+export default {
|
|
|
+ emits: ["success", "closed"],
|
|
|
+ components: {
|
|
|
+ yhUpload,
|
|
|
+ approveDetail
|
|
|
+ },
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ levelDic, typeDic, inWHDic,
|
|
|
+ visible: false,
|
|
|
+ mode: "add",
|
|
|
+ titleMap: {
|
|
|
+ add: "新增政策",
|
|
|
+ edit: "编辑政策",
|
|
|
+ detail: "政策详情",
|
|
|
+ approve: "政策详情"
|
|
|
+ },
|
|
|
+ form: {
|
|
|
id: null,
|
|
|
businessNo: null,
|
|
|
- createId: null,
|
|
|
- createName: null,
|
|
|
- companyName: null,
|
|
|
- deptName: null,
|
|
|
+ status: null,
|
|
|
+ createId: userInfo.id,
|
|
|
+ createName: userInfo.name,
|
|
|
createTime: null,
|
|
|
name: null,
|
|
|
+ companyName: null,
|
|
|
+ deptName: null,
|
|
|
zcLevel: null,
|
|
|
zcType: null,
|
|
|
docNo: null,
|
|
|
contactPhone: null,
|
|
|
abstractContent: null,
|
|
|
- status: null,
|
|
|
score: null,
|
|
|
isInWh: "0",
|
|
|
inWhType: null,
|
|
|
fileList: []
|
|
|
+ },
|
|
|
+
|
|
|
+ rules: {
|
|
|
+ businessNo: [{ required: true }],
|
|
|
+ name: [{ required: true, message: "请输入政策名称" }],
|
|
|
+ zcLevel: [{ required: true, message: "请选择政策等级" }],
|
|
|
+ zcType: [{ required: true, message: "请选择政策类别" }],
|
|
|
+ docNo: [{ required: true, message: "请输入政策文号" }],
|
|
|
+ contactPhone: [{ required: true, message: "请输入联系方式" }],
|
|
|
+ abstractContent: [{ required: true, message: "请输入政策概要" }],
|
|
|
+ score: [{ required: true, message: "请输入分值" }],
|
|
|
+ isInWh: [{ required: true }],
|
|
|
+ inWhType: [{ required: true, message: "请选择入库类型" }],
|
|
|
+ },
|
|
|
+
|
|
|
+ dialog: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ this.getUserDept();
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ init(mode = "add") {
|
|
|
+ this.mode = mode;
|
|
|
+ this.visible = true;
|
|
|
+ return this;
|
|
|
+ },
|
|
|
+
|
|
|
+ setData(id) {
|
|
|
+ API.detail(id).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ for (const key in this.form) {
|
|
|
+ if (key == "fileList") {
|
|
|
+ this.form[key] = res.data[key].map(file => ({ ...file, name: file.originalName, path: file.fileDomain + "/" + file.fileName }));
|
|
|
+ } else this.form[key] = res.data[key] || null;
|
|
|
+ }
|
|
|
+ this.form.updateId = userInfo.id;
|
|
|
+ } else ElMessage.error(res.msg);
|
|
|
});
|
|
|
- for (const key in rowData) {
|
|
|
- if (key == "fileList") {
|
|
|
- rowData[key] = res.data[key].map(file => ({ ...file, name: file.originalName, path: file.fileDomain + "/" + file.fileName }));
|
|
|
- } else rowData[key] = res.data[key] || null;
|
|
|
- }
|
|
|
- form = Object.assign(form, rowData);
|
|
|
- console.log(form)
|
|
|
- } else ElMessage.error(res.msg);
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-const formRef = ref();
|
|
|
-const validateForm = modeValue => {
|
|
|
- if (!formRef || !formRef.value) return;
|
|
|
+ },
|
|
|
+
|
|
|
+ getUserDept() {
|
|
|
+ API.getUserDept(userInfo.deptId).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.form.companyName = res.data.companyName;
|
|
|
+ this.form.deptName = res.data.deptName;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 表单提交方法
|
|
|
+ validateForm(mode) {
|
|
|
+ this.$refs.formRef.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.submit(mode);
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ submit(mode) {
|
|
|
+ API[mode](this.form).then(() => {
|
|
|
+ ElMessage.success("操作成功");
|
|
|
+ this.visible = false;
|
|
|
+ this.$emit("success", mode);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- formRef.value.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- submit(modeValue);
|
|
|
- } else {
|
|
|
- return false;
|
|
|
+ policyApprove(mode) {
|
|
|
+ this.dialog = true;
|
|
|
+ this.$nextTick(() => this.$refs.approveDetail.init(mode).setData(this.form));
|
|
|
}
|
|
|
- });
|
|
|
-}
|
|
|
-const resetForm = () => {
|
|
|
- if (!formRef || !formRef.value) return;
|
|
|
-
|
|
|
- form = reactive({
|
|
|
- createId: userInfo.value.id,
|
|
|
- createName: userInfo.value.name,
|
|
|
- companyName: null,
|
|
|
- deptName: null,
|
|
|
- name: null,
|
|
|
- zcLevel: null,
|
|
|
- zcType: null,
|
|
|
- docNo: null,
|
|
|
- contactPhone: null,
|
|
|
- abstractContent: null,
|
|
|
- fileList: []
|
|
|
- });
|
|
|
- formRef.value.resetFields();
|
|
|
-}
|
|
|
-
|
|
|
-const submit = modeValue => {
|
|
|
- API[modeValue](form).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- visible.value = false;
|
|
|
- ElMessage.success("操作成功");
|
|
|
- } else ElMessage.error(res.msg);
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-const approveRef = ref();
|
|
|
-const policyApprove = (modeValue) => {
|
|
|
- approveRef.value.init(modeValue, form);
|
|
|
-}
|
|
|
-const form_reset = () => {
|
|
|
- setData(form.id);
|
|
|
- approveRef.value.resetForm();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-defineExpose({ init, resetForm });
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|