zhuangyunsheng 1 rok pred
rodič
commit
e2e11522fe

+ 2 - 2
.env.development

@@ -11,10 +11,10 @@ VITE_BASE_URL = "/dev-api"
 VITE_BASE_MOCK_URL = "/mock-api"
 
 # boot服务端接口路径
-# VITE_BASE_SERVER_URL = "http://192.168.101.93:8000"
+VITE_BASE_SERVER_URL = "http://192.168.101.93:8000"
 # VITE_BASE_SERVER_URL = "http://10.206.20.153:8000" # 青岛港-内网
 # VITE_BASE_SERVER_URL = "http://192.168.43.231:8000" # 热点
-VITE_BASE_SERVER_URL = "http://192.168.1.133:8000" # 青岛港-7楼
+# VITE_BASE_SERVER_URL = "http://192.168.1.133:8000" # 青岛港-7楼
 # 微前端-工作流
 VITE_WORKFLOW_URL = "http://localhost:1888/"
 # 微前端-代码生成器

+ 58 - 69
src/views/policyShare/approve.vue

@@ -1,5 +1,5 @@
 <template>
-    <el-dialog v-model="visible" :title="titleMap[mode]" :width="500" top="20vh" @closed="$emit('closed', mode)">
+    <el-dialog v-model="visible" :title="titleMap[mode]" :width="500" top="20vh" @closed="$emit('closed')">
         <el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
             <el-row>
                 <template v-if="mode == 'agree'">
@@ -10,8 +10,8 @@
                     </el-col>
                     <el-col :span="24">
                         <el-form-item label="是否入库" prop="isInWh">
-                            <el-radio-group v-model="form.isInWh" @change="radioChange">
-                                <el-radio v-for="(label, key) in inWHDic" :key="key" :label="label" :value="key"></el-radio>
+                            <el-radio-group v-model="form.isInWh" @change="form.inWhType = null">
+                                <el-radio v-for="(label, key) in inWHDic" :key="key" :label="label" :value="parseInt(key)"></el-radio>
                             </el-radio-group>
                         </el-form-item>
                     </el-col>
@@ -38,75 +38,64 @@
     </el-dialog>
 </template>
 
-<script setup>
-import API from "@/api/policy/share.js";
-import { policyShareDict } from "./main.js";
-
-const $emit = defineEmits(["closed"]);
-const { storageTypeDic, inWHDic } = policyShareDict();
-
-const visible = ref(false);
-const mode = ref("agree");
-const titleMap = reactive({
-    agree: "考核评分",
-    disagree: "退回意见"
-});
-
-let form = reactive({
-    score: null,
-    isInWh: "0",
-    inWhType: null,
-    remark: "不同意"
-});
-const rules = reactive({
-    score: [{ required: true, message: "请输入分值" }],
-    isInWh: [{ required: true }],
-    inWhType: [{ required: true, message: "请选择入库类型" }],
-    remark: [{ required: true, message: "请输入退回意见" }]
-});
-
-const init = (modeValue = "agree", data) => {
-    mode.value = modeValue;
-    visible.value = true;
-
-    form = Object.assign(data, form);
-}
-
-const formRef = ref();
-const resetForm = () => {
-    if (!formRef || !formRef.value) return;
-
-    form = reactive({
-        score: null,
-        isInWh: "0",
-        inWhType: null,
-        remark: "不同意"
-    });
-    formRef.value.resetFields();
-}
-
-const submit = () => {
-    if (!formRef || !formRef.value) return;
-
-    formRef.value.validate(valid => {
-        if (valid) {
-            API[mode.value](form).then(res => {
-                if (res.code === 200) {
-                    visible.value = false;
-                    ElMessage.success("操作成功");
-                } else ElMessage.error(res.msg);
+<script>
+import API from "@/api/policy/share";
+import { storageTypeDic, inWHDic } from "./main";
+
+export default {
+    emits: ["success", "closed"],
+
+    data() {
+        return {
+            storageTypeDic, inWHDic,
+
+            visible: false,
+            mode: "agree",
+            titleMap: {
+                agree: "考核评分",
+                disagree: "退回意见"
+            },
+
+            form: {}, // remark: "不同意"
+            rules: {
+                score: [{ required: true, message: "请输入分值" }],
+                isInWh: [{ required: true }],
+                inWhType: [{ required: true, message: "请选择入库类型" }],
+                remark: [{ required: true, message: "请输入退回意见" }]
+            }
+        }
+    },
+
+    methods: {
+        init(mode = "agree") {
+            this.mode = mode;
+            this.visible = true;
+            return this;
+        },
+
+        setData(data) {
+            this.form = Object.assign({}, data);
+            this.form.isInWh = 0;
+            this.form.inWhType = null;
+        },
+
+        submit() {
+            this.$refs.formRef.validate(valid => {
+                if (valid) {
+                    API[this.mode](this.form).then(res => {
+                        if (res.code === 200) {
+                            this.visible = false;
+                            ElMessage.success("操作成功");
+                            $emit("success", this.form.id)
+                        } else ElMessage.error(res.msg);
+                    });
+                } else {
+                    return false;
+                }
             });
-        } else {
-            return false;
         }
-    });
-}
-
-const radioChange = e => {
-    form.inWhType = null;
+    }
 }
-
-defineExpose({ init, resetForm });
 </script>
 
 <style lang="scss" scoped>

+ 105 - 131
src/views/policyShare/dialog.vue

@@ -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>

+ 103 - 88
src/views/policyShare/index.vue

@@ -73,7 +73,7 @@
                     <template #default="scope">
                         <template v-if="scope.row.status == 'active' || scope.row.status == 'inactive'">
                             <el-button type="primary" icon="edit" link @click="table_edit(scope.row)">修改</el-button>
-                            <el-button type="primary" icon="edit" link @click="table_update(scope.row, 'saveApprove')">提交</el-button>
+                            <el-button type="primary" icon="edit" link @click="table_update(scope.row)">提交</el-button>
                             <el-button type="primary" icon="delete" link @click="table_del(scope.row)">删除</el-button>
                         </template>
                         <el-button v-if="scope.row.status == 'approve' || scope.row.status == 'done'" type="primary" link @click="table_edit(scope.row, 'detail')">详情</el-button>
@@ -87,102 +87,117 @@
         </div>
     </el-card>
 
-    <policy-detail ref="detailRef" @closed="form_reset"></policy-detail>
+    <policy-detail v-if="dialog" ref="policyDetail" @success="reloadTable" @closed="dialog = false"></policy-detail>
 </template>
 
-<script setup>
-import API from "@/api/policy/share.js"
-import { policyShareDict } from "./main.js";
+<script>
+import API from "@/api/policy/share"
+import { levelDic, typeDic, statusDic, inWHDic, storageTypeDic } from "./main";
 import yhPagination from "@/components/Pagination/index.vue";
-import PolicyDetail from "./dialog.vue";
-
-const loading = ref(false);
-const params = reactive({
-    page: 1,
-    size: 10
-});
-const total = ref(0);
-let tableData = reactive([]);
-const { levelDic, typeDic, statusDic, inWHDic, storageTypeDic } = policyShareDict();
-
-// table format
-const formatStatus = ({ status, isInWh }) => {
-    if (status == "done" && isInWh == 1) return "审核入库"
-    return statusDic[status] || "";
-}
-const formatInWh = isInWh => {
-    return inWHDic[isInWh] || "";
-}
-// table format
+import policyDetail from "./dialog.vue";
 
-const reset = () => {
-    for (const key in params) {
-        if (key == "page") params[key] = 1;
-        else if (key == "size") params[key] = 10;
-        else params[key] = null;
-    }
-    reloadTable();
-}
+export default {
+    components: {
+        yhPagination,
+        policyDetail
+    },
 
-const reloadTable = (mode = "add") => {
-    if (mode == "add") params.page = 1;
-
-    loading.value = true;
-    API.get(params).then(res => {
-        loading.value = false;
-        if (res.code === 200) {
-            tableData = reactive(res.data.records);
-            total.value = res.data.total;
-        } else ElMessage.error(res.msg);
-    }).catch(() => loading.value = false);
-}
-reloadTable();
+    data() {
+        return {
+            levelDic, typeDic, statusDic, inWHDic, storageTypeDic,
 
-// 弹出框
-const detailRef = ref();
-const form_reset = mode => {
-    detailRef.value.resetForm();
-    reloadTable(mode);
-}
-const table_add = () => {
-    detailRef.value.init();
-}
-const table_edit = (row, mode = "edit") => {
-    detailRef.value.init(mode, row.id);
-}
-const table_del = row => {
-    ElMessageBox.confirm("是否确认删除?", "删除警告", {
-        type: "warning",
-        confirmButtonText: "确定",
-        cancelButtonText: "取消"
-    }).then(() => {
-        API.del({ ids: row.id }).then(res => {
-            if (res.code == 200) {
-                ElMessage.success(res.msg);
-                reloadTable();
-            } else ElMessage.warning(res.msg);
-        });
-    });
-}
+            loading: false,
+            params: {
+                page: 1,
+                size: 10
+            },
+
+            total: 0,
+            tableData: [],
+
+            dialog: false
+        }
+    },
 
-const table_update = (row, mode) => {
-    const msg = mode == "withdraw" && "撤回" || "提交";
-    ElMessageBox.confirm(`是否确认${msg}?`, `${msg}警告`, {
-        type: "warning",
-        confirmButtonText: "确定",
-        cancelButtonText: "取消"
-    }).then(() => {
-        API[mode](row).then(res => {
-            if (res.code === 200) {
-                ElMessage.success(`已${msg}`);
-                reloadTable();
-            } else ElMessage.error(res.msg);
-        });
-    });
+    mounted() {
+        this.reloadTable();
+    },
+
+    methods: {
+        formatStatus({ status, isInWh }) {
+            if (status == "done" && isInWh == 1) return "审核入库"
+            return statusDic[status] || "";
+        },
+
+        formatInWh (value)  {
+            return inWHDic[value] || "";
+        },
+
+        reloadTable(mode = "add") {
+            if (mode == "add") this.params.page = 1;
+
+            this.loading = true;
+            API.get(this.params).then(res => {
+                this.loading = false;
+                if (res.code === 200) {
+                    this.tableData = res.data.records;
+                    this.total = res.data.total;
+                } else ElMessage.error(res.msg);
+            }).catch(() => this.loading = false);
+        },
+
+        reset() {
+            for (const key in this.params) {
+                if (key == "page") this.params[key] = 1;
+                else if (key == "size") this.params[key] = 10;
+                else this.params[key] = null;
+            }
+            this.reloadTable();
+        },
+
+        table_add() {
+            this.dialog = true;
+            this.$nextTick(() => this.$refs.policyDetail.init());
+        },
+
+        table_edit(row, mode = "edit") {
+            this.dialog = true;
+            this.$nextTick(() => this.$refs.policyDetail.init(mode).setData(row.id));
+        },
+
+        table_del(row) {
+            ElMessageBox.confirm("是否确认删除?", "删除警告", {
+                type: "warning",
+                confirmButtonText: "确定",
+                cancelButtonText: "取消"
+            }).then(() => {
+                API.del({ ids: row.id }).then(res => {
+                    if (res.code == 200) {
+                        ElMessage.success("操作成功");
+                        this.reloadTable();
+                    } else ElMessage.warning(res.msg);
+                });
+            });
+        },
+
+        table_update(row, mode = "saveApprove") {
+            const msg = mode == "withdraw" && "撤回" || "提交";
+            ElMessageBox.confirm(`是否确认${msg}?`, `${msg}警告`, {
+                type: "warning",
+                confirmButtonText: "确定",
+                cancelButtonText: "取消"
+            }).then(() => {
+                API[mode](row).then(res => {
+                    if (res.code === 200) {
+                        ElMessage.success("操作成功");
+                        this.reloadTable();
+                    } else ElMessage.error(res.msg);
+                });
+            });
+        }
+    }
 }
 </script>
 
 <style lang="scss" scoped>
-.policy-container {
-}
 </style>

+ 10 - 14
src/views/policyShare/main.js

@@ -1,14 +1,10 @@
-export function policyShareDict() {
-    const levelDic = reactive(["国家级", "省部级", "市区级"]);
-    const typeDic = reactive(["财税政策", "人才支持", "市场开拓", "智慧创新", "招商引资", "技术改造", "法律法规", "营商环境", "企业管理"]);
-    const statusDic = reactive({
-        active: "保存",
-        approve: "审核",
-        done: "审核通过",
-        inactive: "退回"
-    });
-    const storageTypeDic = reactive(["政策类", "解读类"]);
-    const inWHDic = reactive({ 0: "否", 1: "是" });
-
-    return { levelDic, typeDic, statusDic, storageTypeDic, inWHDic }
-}
+export const levelDic = ["国家级", "省部级", "市区级"];
+export const typeDic = ["财税政策", "人才支持", "市场开拓", "智慧创新", "招商引资", "技术改造", "法律法规", "营商环境", "企业管理"];
+export const statusDic = {
+    active: "保存",
+    approve: "审核",
+    done: "审核通过",
+    inactive: "退回"
+};
+export const storageTypeDic = ["政策类", "解读类"];
+export const inWHDic = { 0: "否", 1: "是" };

+ 53 - 44
src/views/toDo/index.vue

@@ -42,57 +42,66 @@
         </div>
     </el-card>
 
-    <policy-share-detail ref="shareDetailRef" @closed="form_reset"></policy-share-detail>
+    <policy-share-detail v-if="dialog" ref="policy_share" @closed="reloadTable(), dialog = false"></policy-share-detail>
 </template>
 
-<script setup>
-import API from "@/api/policy/todo.js"
-import { policyShareDict } from "@/views/policyShare/main.js";
+<script>
+import API from "@/api/policy/todo"
+import { typeDic } from "@/views/policyShare/main";
 import yhPagination from "@/components/Pagination/index.vue";
 import PolicyShareDetail from "@/views/policyShare/dialog.vue";
 
-const loading = ref(false);
-const params = reactive({
-    page: 1,
-    size: 10
-});
-const total = ref(0);
-let tableData = reactive([]);
-const { typeDic } = policyShareDict();
+export default {
+    components: {
+        yhPagination,
+        PolicyShareDetail
+    },
 
-const reset = () => {
-    for (const key in params) {
-        if (key == "page") params[key] = 1;
-        else if (key == "size") params[key] = 10;
-        else params[key] = null;
-    }
-    reloadTable();
-}
+    data() {
+        return {
+            typeDic,
+            loading: false,
+            params: {
+                page: 1,
+                size: 10
+            },
 
-const reloadTable = () => {
-    loading.value = true;
-    API.get(params).then(res => {
-        loading.value = false;
-        if (res.code === 200) {
-            tableData = reactive(res.data.records);
-            total.value = res.data.total;
-        } else ElMessage.error(res.msg);
-    }).catch(() => loading.value = false);
-}
-reloadTable();
+            total: 0,
+            tableData: [],
 
-// 弹出框
-const shareDetailRef = ref();
-const form_reset = () => {
-    shareDetailRef && shareDetailRef.value && shareDetailRef.value.resetForm();
-    reloadTable();
-}
-const table_detail = ({ refId, refType }) => {
-    refType == "policy_share" && shareDetailRef.value.init("approve", refId);
-}
-</script>
+            dialog: false
+        }
+    },
+
+    mounted() {
+        this.reloadTable();
+    },
 
-<style lang="scss" scoped>
-.policy-container {
+    methods: {
+        reloadTable() {
+            this.loading = true;
+            API.get(this.params).then(res => {
+                this.loading = false;
+                if (res.code === 200) {
+                    this.tableData = res.data.records;
+                    this.total = res.data.total;
+                } else ElMessage.error(res.msg);
+            }).catch(() => this.loading = false);
+        },
+    
+        reset() {
+            for (const key in this.params) {
+                if (key == "page") this.params[key] = 1;
+                else if (key == "size") this.params[key] = 10;
+                else this.params[key] = null;
+            }
+            this.reloadTable();
+        },
+    
+        table_detail({ refId, refType }) {
+            this.dialog = true;
+            this.$nextTick(() => this.$refs[refType].init("approve").setData(refId));
+        }
+    }
 }
-</style>
+</script>