Jelajahi Sumber

Merge branch 'master' of https://git.agilestar.cn/spfm-group/spfm-market-front

houlf 3 tahun lalu
induk
melakukan
f90a7a4456

+ 349 - 0
src/pages/main/performance/common/export.js

@@ -0,0 +1,349 @@
+// import { createCellPos } from './translateNumToLetter'
+const Excel = require("exceljs");
+import FileSaver from "file-saver";
+export var exportExcel = function (luckysheet, value) {
+    // 参数为luckysheet.getluckysheetfile()获取的对象
+    // 1.创建工作簿,可以为工作簿添加属性
+    const workbook = new Excel.Workbook();
+    // 2.创建表格,第二个参数可以配置创建什么样的工作表
+    if (Object.prototype.toString.call(luckysheet) === "[object Object]") {
+        luckysheet = [luckysheet];
+    }
+    luckysheet.forEach(function (table) {
+        if (table.data.length === 0) return true;
+        // ws.getCell('B2').fill = fills.
+        const worksheet = workbook.addWorksheet(table.name);
+        const merge = (table.config && table.config.merge) || {};
+        const borderInfo = (table.config && table.config.borderInfo) || {};
+        // 3.设置单元格合并,设置单元格边框,设置单元格样式,设置值
+        setStyleAndValue(table.data, worksheet);
+        setMerge(merge, worksheet);
+        setBorder(borderInfo, worksheet);
+        return true;
+    });
+
+    // return
+    // 4.写入 buffer
+    const buffer = workbook.xlsx.writeBuffer().then((data) => {
+        // console.log('data', data)
+        const blob = new Blob([data], {
+            type: "application/vnd.ms-excel;charset=utf-8",
+        });
+        console.log("导出成功!");
+        FileSaver.saveAs(blob, `${value}.xlsx`);
+    });
+    return buffer;
+};
+
+var setMerge = function (luckyMerge = {}, worksheet) {
+    const mergearr = Object.values(luckyMerge);
+    mergearr.forEach(function (elem) {
+        // elem格式:{r: 0, c: 0, rs: 1, cs: 2}
+        // 按开始行,开始列,结束行,结束列合并(相当于 K10:M12)
+        worksheet.mergeCells(
+            elem.r + 1,
+            elem.c + 1,
+            elem.r + elem.rs,
+            elem.c + elem.cs
+        );
+    });
+};
+
+var setBorder = function (luckyBorderInfo, worksheet) {
+    if (!Array.isArray(luckyBorderInfo)) return;
+    // console.log('luckyBorderInfo', luckyBorderInfo)
+    luckyBorderInfo.forEach(function (elem) {
+        // 现在只兼容到borderType 为range的情况
+        // console.log('ele', elem)
+        if (elem.rangeType === "range") {
+            let border = borderConvert(elem.borderType, elem.style, elem.color);
+            let rang = elem.range[0];
+            // console.log('range', rang)
+            let row = rang.row;
+            let column = rang.column;
+            for (let i = row[0] + 1; i < row[1] + 2; i++) {
+                for (let y = column[0] + 1; y < column[1] + 2; y++) {
+                    worksheet.getCell(i, y).border = border;
+                }
+            }
+        }
+        if (elem.rangeType === "cell") {
+            // col_index: 2
+            // row_index: 1
+            // b: {
+            //   color: '#d0d4e3'
+            //   style: 1
+            // }
+            const { col_index, row_index } = elem.value;
+            const borderData = Object.assign({}, elem.value);
+            delete borderData.col_index;
+            delete borderData.row_index;
+            let border = addborderToCell(borderData, row_index, col_index);
+            // console.log('bordre', border, borderData)
+            worksheet.getCell(row_index + 1, col_index + 1).border = border;
+        }
+        // console.log(rang.column_focus + 1, rang.row_focus + 1)
+        // worksheet.getCell(rang.row_focus + 1, rang.column_focus + 1).border = border
+    });
+};
+var setStyleAndValue = function (cellArr, worksheet) {
+    if (!Array.isArray(cellArr)) return;
+    cellArr.forEach(function (row, rowid) {
+        row.every(function (cell, columnid) {
+            if (!cell) return true;
+            let fill = fillConvert(cell.bg);
+
+            let font = fontConvert(
+                cell.ff,
+                cell.fc,
+                cell.bl,
+                cell.it,
+                cell.fs,
+                cell.cl,
+                cell.ul
+            );
+            let alignment = alignmentConvert(
+                cell.vt,
+                cell.ht,
+                cell.tb,
+                cell.tr
+            );
+            let value = "";
+
+            if (cell.f) {
+                value = { formula: cell.f, result: cell.v };
+            } else if (!cell.v && cell.ct && cell.ct.s) {
+                // xls转为xlsx之后,内部存在不同的格式,都会进到富文本里,即值不存在与cell.v,而是存在于cell.ct.s之后
+                // value = cell.ct.s[0].v
+                cell.ct.s.forEach((arr) => {
+                    value += arr.v;
+                });
+            } else {
+                value = cell.v;
+            }
+            //  style 填入到_value中可以实现填充色
+            let letter = createCellPos(columnid);
+            let target = worksheet.getCell(letter + (rowid + 1));
+            // console.log('1233', letter + (rowid + 1))
+            // eslint-disable-next-line no-unused-vars
+            for (const key in fill) {
+                target.fill = fill;
+                break;
+            }
+            target.font = font;
+            target.alignment = alignment;
+            target.value = value;
+
+            return true;
+        });
+    });
+};
+
+var fillConvert = function (bg) {
+    if (!bg) {
+        return {};
+    }
+    // const bgc = bg.replace('#', '')
+    let fill = {
+        type: "pattern",
+        pattern: "solid",
+        fgColor: { argb: bg.replace("#", "") },
+    };
+    return fill;
+};
+
+var fontConvert = function (
+    ff = 0,
+    fc = "#000000",
+    bl = 0,
+    it = 0,
+    fs = 10,
+    cl = 0,
+    ul = 0
+) {
+    // luckysheet:ff(样式), fc(颜色), bl(粗体), it(斜体), fs(大小), cl(删除线), ul(下划线)
+    const luckyToExcel = {
+        0: "微软雅黑",
+        1: "宋体(Song)",
+        2: "黑体(ST Heiti)",
+        3: "楷体(ST Kaiti)",
+        4: "仿宋(ST FangSong)",
+        5: "新宋体(ST Song)",
+        6: "华文新魏",
+        7: "华文行楷",
+        8: "华文隶书",
+        9: "Arial",
+        10: "Times New Roman ",
+        11: "Tahoma ",
+        12: "Verdana",
+        num2bl: function (num) {
+            return num === 0 ? false : true;
+        },
+    };
+    // 出现Bug,导入的时候ff为luckyToExcel的val
+
+    let font = {
+        name: typeof ff === "number" ? luckyToExcel[ff] : ff,
+        family: 1,
+        size: fs,
+        color: { argb: fc.replace("#", "") },
+        bold: luckyToExcel.num2bl(bl),
+        italic: luckyToExcel.num2bl(it),
+        underline: luckyToExcel.num2bl(ul),
+        strike: luckyToExcel.num2bl(cl),
+    };
+
+    return font;
+};
+
+var alignmentConvert = function (
+    vt = "default",
+    ht = "default",
+    tb = "default",
+    tr = "default"
+) {
+    // luckysheet:vt(垂直), ht(水平), tb(换行), tr(旋转)
+    const luckyToExcel = {
+        vertical: {
+            0: "middle",
+            1: "top",
+            2: "bottom",
+            default: "top",
+        },
+        horizontal: {
+            0: "center",
+            1: "left",
+            2: "right",
+            default: "left",
+        },
+        wrapText: {
+            0: false,
+            1: false,
+            2: true,
+            default: false,
+        },
+        textRotation: {
+            0: 0,
+            1: 45,
+            2: -45,
+            3: "vertical",
+            4: 90,
+            5: -90,
+            default: 0,
+        },
+    };
+
+    let alignment = {
+        vertical: luckyToExcel.vertical[vt],
+        horizontal: luckyToExcel.horizontal[ht],
+        wrapText: luckyToExcel.wrapText[tb],
+        textRotation: luckyToExcel.textRotation[tr],
+    };
+    return alignment;
+};
+
+var borderConvert = function (borderType, style = 1, color = "#000") {
+    // 对应luckysheet的config中borderinfo的的参数
+    if (!borderType) {
+        return {};
+    }
+    const luckyToExcel = {
+        type: {
+            "border-all": "all",
+            "border-top": "top",
+            "border-right": "right",
+            "border-bottom": "bottom",
+            "border-left": "left",
+        },
+        style: {
+            0: "none",
+            1: "thin",
+            2: "hair",
+            3: "dotted",
+            4: "dashDot", // 'Dashed',
+            5: "dashDot",
+            6: "dashDotDot",
+            7: "double",
+            8: "medium",
+            9: "mediumDashed",
+            10: "mediumDashDot",
+            11: "mediumDashDotDot",
+            12: "slantDashDot",
+            13: "thick",
+        },
+    };
+    let template = {
+        style: luckyToExcel.style[style],
+        color: { argb: color.replace("#", "") },
+    };
+    let border = {};
+    if (luckyToExcel.type[borderType] === "all") {
+        border["top"] = template;
+        border["right"] = template;
+        border["bottom"] = template;
+        border["left"] = template;
+    } else {
+        border[luckyToExcel.type[borderType]] = template;
+    }
+    // console.log('border', border)
+    return border;
+};
+
+function addborderToCell(borders) {
+    let border = {};
+    const luckyExcel = {
+        type: {
+            l: "left",
+            r: "right",
+            b: "bottom",
+            t: "top",
+        },
+        style: {
+            0: "none",
+            1: "thin",
+            2: "hair",
+            3: "dotted",
+            4: "dashDot", // 'Dashed',
+            5: "dashDot",
+            6: "dashDotDot",
+            7: "double",
+            8: "medium",
+            9: "mediumDashed",
+            10: "mediumDashDot",
+            11: "mediumDashDotDot",
+            12: "slantDashDot",
+            13: "thick",
+        },
+    };
+    // console.log('borders', borders)
+    for (const bor in borders) {
+        // console.log(bor)
+        if (borders[bor].color.indexOf("rgb") === -1) {
+            border[luckyExcel.type[bor]] = {
+                style: luckyExcel.style[borders[bor].style],
+                color: { argb: borders[bor].color.replace("#", "") },
+            };
+        } else {
+            border[luckyExcel.type[bor]] = {
+                style: luckyExcel.style[borders[bor].style],
+                color: { argb: borders[bor].color },
+            };
+        }
+    }
+
+    return border;
+}
+
+function createCellPos(n) {
+    let ordA = "A".charCodeAt(0);
+
+    let ordZ = "Z".charCodeAt(0);
+    let len = ordZ - ordA + 1;
+    let s = "";
+    while (n >= 0) {
+        s = String.fromCharCode((n % len) + ordA) + s;
+
+        n = Math.floor(n / len) - 1;
+    }
+    return s;
+}

+ 10 - 1
src/pages/main/performance/components/dialog.vue

@@ -1,5 +1,6 @@
 <template>
   <el-dialog
+    :modal="modal"
     :title="title"
     :visible.sync="visible"
     :fullscreen="fullscreen"
@@ -7,6 +8,7 @@
     :before-close="handleCancel"
     :modal-append-to-body="false"
     :width="width"
+    :destroy-on-close="destroy"
   >
     <!-- 表格主体部分 -->
     <slot></slot>
@@ -45,9 +47,16 @@ export default {
       type: Boolean,
       default: false,
     },
+    modal: {
+      type: Boolean,
+      default: true,
+    },
+    destroy: {
+      type: Boolean,
+      default: false
+    }
   },
   mounted() {
-    console.log("我被初始化了");
   },
   methods: {
     //   确定的回调

+ 310 - 20
src/pages/main/performance/components/sheet.vue

@@ -2,49 +2,226 @@
  * @Author       : yuanrunwei
  * @Date         : 2021-12-04 14:23:58
  * @LastEditors  : yuanrunwei
- * @LastEditTime : 2021-12-15 19:38:31
+ * @LastEditTime : 2021-12-24 10:05:55
  * @FilePath     : \spfm-market-front\src\pages\main\performance\components\sheet.vue
 -->
 
 <template>
     <div class="sheet-container">
         <div class="flex-justify-align-end margin-bottom-20">
-            <el-upload
-                class="margin-right-10"
-                action
-                :on-change="handleChange"
-                :show-file-list="false"
+            <el-button type="primary" @click="handleVisible"
+                >权限设置</el-button
             >
-                <el-button type="primary">上传</el-button>
-            </el-upload>
-            <el-button type="primary" @click="handleSave">保存</el-button>
             <el-button type="primary" @click="handleDownload">导出</el-button>
-            <el-button type="primary">返回</el-button>
-            <el-button type="primary">全屏显示</el-button>
+            <el-button type="primary" @click="handleFullscreen()"
+                >全屏显示</el-button
+            >
+            <template v-if="type === 'edit'">
+                <el-upload
+                    class="margin-right-10 margin-left-10"
+                    action
+                    :on-change="handleChange"
+                    :show-file-list="false"
+                >
+                    <el-button type="primary">上传</el-button>
+                </el-upload>
+                <el-button
+                    type="primary"
+                    @click="handleSave"
+                    :disabled="handleForbid()"
+                    >保存</el-button
+                >
+            </template>
         </div>
         <div id="luckysheet" class="sheet-container-block"></div>
+        <simple-dialog
+            title="权限设置"
+            :visible="visible"
+            :modal="false"
+            width="700px"
+            @confirm="handlePower"
+            @cancel="handleVisible"
+        >
+            <el-form ref="form" :model="form" label-width="100px">
+                <el-form-item
+                    label="可编辑列"
+                    prop="array"
+                    :rules="{
+                        required: true,
+                        message: '可编辑列不能为空',
+                        trigger: 'change',
+                    }"
+                    ><el-select
+                        v-model="form.array"
+                        placeholder="可编辑列"
+                        multiple
+                    >
+                        <el-option
+                            v-for="(value, index) in 10"
+                            :key="index"
+                            :label="index"
+                            :value="index"
+                        >
+                        </el-option> </el-select
+                ></el-form-item>
+                <el-form-item
+                    label="权限规则"
+                    prop="type"
+                    :rules="{
+                        required: true,
+                        message: '权限规则不能为空',
+                        trigger: 'change',
+                    }"
+                >
+                    <el-select v-model="form.type">
+                        <el-option
+                            v-for="item in type_options"
+                            :key="item.value"
+                            :label="item.label"
+                            :value="item.value"
+                        ></el-option> </el-select
+                ></el-form-item>
+                <el-form-item
+                    label="负责人"
+                    prop="charge"
+                    :rules="{
+                        required: true,
+                        message: '负责人不能为空',
+                        trigger: 'blur',
+                    }"
+                >
+                    <div
+                        class="flex-justify-start"
+                        v-for="(item, index) in form.charge"
+                        :key="index"
+                    >
+                        <el-select
+                            v-model="item.key"
+                            class="margin-bottom-20 margin-right-10 flex-1"
+                            placeholder="请选择指定列/行"
+                            multiple
+                        >
+                            <el-option
+                                v-for="(value, index) in 10"
+                                :key="index"
+                                :label="index"
+                                :value="index"
+                            >
+                            </el-option>
+                        </el-select>
+                        <el-select
+                            class="margin-bottom-20"
+                            placeholder="请选择负责人"
+                            v-model="item.value"
+                            filterable
+                        >
+                            <el-option
+                                v-for="({ label, value }, index) in charge_list"
+                                :key="index"
+                                :label="label"
+                                :value="value"
+                            ></el-option>
+                        </el-select>
+                    </div>
+
+                    <div>
+                        <el-button @click.prevent="handleCharge('add')"
+                            >添加</el-button
+                        >
+                        <el-button
+                            v-if="form.charge.length - 1"
+                            @click.prevent="handleCharge('delete')"
+                            >删除</el-button
+                        >
+                    </div>
+                </el-form-item>
+            </el-form>
+        </simple-dialog>
     </div>
 </template>
 
 <script>
 import luckyexcel from "luckyexcel";
+import { exportExcel } from "../common/export";
+import simpleDialog from "./dialog.vue";
 export default {
+    components: {
+        simpleDialog,
+    },
+    props: {
+        type: {
+            type: String,
+            default: "view",
+        },
+        id: {
+            type: Number,
+            default: null,
+        },
+    },
     data() {
         return {
-            row_list: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
-            column_list: [4, 5, 6, 7, 8],
+            form: {
+                charge: [{ value: "" }],
+            },
+            visible: false,
+            row_list: [],
+            column_list: [],
+            charge_list: [],
+            type_options: [
+                {
+                    value: 1,
+                    label: "按行",
+                },
+                {
+                    value: 2,
+                    label: "按列",
+                },
+            ],
         };
     },
     methods: {
         handleInit() {
-            this.handleCreate();
+            if (this.id) {
+                this.handleQuery();
+            } else {
+                this.handleCreate();
+            }
         },
         handleAllow({ row, column }) {
             return (
                 this.row_list.includes(row) && this.column_list.includes(column)
             );
         },
-        async handleCreate({ file, json, type } = {}) {
+        async handleQuery() {
+            const {
+                data: { templateContent, templateName },
+            } = await this.$http({
+                url: "/market/CMKFileTemplate/QueryCMKFileTemplateById",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    templateId: this.id,
+                },
+            });
+            this.handleCreate({
+                json: JSON.parse(templateContent),
+                name: templateName,
+                type: "json",
+            });
+        },
+        handleForbid() {
+            const object = {};
+            const { array, type, charge } = this.form;
+            charge.map(({ key, value }) => {
+                if (key && value) {
+                    object[key] = value;
+                }
+            });
+            return !(Object.keys(object).length && array.length && type);
+        },
+        async handleCreate({ file, json, type, name } = {}) {
             let that = this;
             const options = {
                 container: "luckysheet",
@@ -97,7 +274,13 @@ export default {
                     break;
                 case "json":
                     if (json) {
-                        options.data = [json];
+                        options.data = [
+                            {
+                                ...json,
+                                zoomRatio: 0.75,
+                            },
+                        ];
+                        options.title = name;
                     }
                     break;
             }
@@ -107,16 +290,123 @@ export default {
         async handleChange(response) {
             this.handleCreate({ file: response.raw, type: "file" });
         },
-        handleDownload() {},
-        handleSave() {
+        handleDownload() {
+            exportExcel(
+                window.luckysheet.getAllSheets(),
+                window.luckysheet.getWorkbookName()
+            );
+        },
+        async handleSave() {
             const sheet_name = window.luckysheet.getSheet().name;
             const data = window.luckysheet.getSheet(sheet_name);
-            console.log(JSON.stringify(data.data));
-            this.handleCreate({ json: data, type: "json" });
+            const workbook_name = window.luckysheet.getWorkbookName();
+            const {
+                data: { body },
+            } = await this.$http({
+                url: "/market/CMKFileTemplate/CMKFileTemplateAdd",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    templateContent: JSON.stringify(data),
+                    templateName: workbook_name,
+                },
+            });
+            const object = {};
+            const { array, charge, type } = this.form;
+            charge.map(({ key, value }) => {
+                if (key && value) {
+                    object[key] = value;
+                }
+            });
+            await this.$http({
+                url: "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityAdd",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    allowEditingColumns: array.join(","),
+                    auth: JSON.stringify(object),
+                    templateId: body,
+                    type,
+                },
+            });
+            this.$message.success("保存成功");
+        },
+        handlePower() {
+            this.$refs["form"].validate((valid) => {
+                if (valid) {
+                    if (this.handleForbid()) {
+                        this.$message.error("请选择负责人编辑权限");
+                        return false;
+                    }
+                    this.handleVisible();
+                    this.$message.success("设置成功");
+                }
+            });
+        },
+        handleCharge(type) {
+            switch (type) {
+                case "add":
+                    this.form.charge.push({
+                        value: "",
+                    });
+                    break;
+                case "delete":
+                    this.form.charge.pop();
+                    break;
+            }
+        },
+        handleVisible() {
+            this.visible = !this.visible;
+        },
+        handleFullscreen() {
+            const element = document.body;
+            const is_fullscreen =
+                document.fullScreen ||
+                document.mozFullScreen ||
+                document.webkitIsFullScreen;
+            if (!is_fullscreen) {
+                //进入全屏,多重短路表达式
+                (element.requestFullscreen && element.requestFullscreen()) ||
+                    (element.mozRequestFullScreen &&
+                        element.mozRequestFullScreen()) ||
+                    (element.webkitRequestFullscreen &&
+                        element.webkitRequestFullscreen()) ||
+                    (element.msRequestFullscreen &&
+                        element.msRequestFullscreen());
+            } else {
+                //退出全屏,三目运算符
+                document.exitFullscreen
+                    ? document.exitFullscreen()
+                    : document.mozCancelFullScreen
+                    ? document.mozCancelFullScreen()
+                    : document.webkitExitFullscreen
+                    ? document.webkitExitFullscreen()
+                    : "";
+            }
+        },
+        handleChargeList() {
+            this.$http({
+                url: "/market/techcentergj/queryLeaderList",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {},
+            }).then((response) => {
+                this.charge_list = response.data.map((element) => ({
+                    label: `${element.ou} ${element.secLeaderName}`,
+                    value: `${element.secLeaderLogin},${element.secLeaderName}`,
+                }));
+            });
         },
     },
     mounted() {
         this.handleInit();
+        this.handleChargeList();
     },
 };
 </script>

+ 38 - 18
src/pages/main/performance/department.vue

@@ -262,8 +262,8 @@ export default {
         {
           label: "状态",
           props: "status",
-          type:'dictionary',
-          dictionary: {"0":"待处理","1":"待汇总","2":"待审批","3":"已完成"},
+          type: "dictionary",
+          dictionary: { 0: "待处理", 1: "待汇总", 2: "待审批", 3: "已完成" },
         },
       ],
     };
@@ -295,6 +295,8 @@ export default {
           precautions: "填报注意事项",
           endTime: new Date(),
           loginNameStr: "发起人",
+          id:23,
+          templateContent:'templateContent'
         });
       });
     },
@@ -334,21 +336,22 @@ export default {
       this.track_visible = true;
     },
     handleTransfer() {
-      const object = {
-        ...JSON.parse(sessionStorage.global_data)[0],
-        department_status: "待审批",
-      };
-      sessionStorage.setItem("global_data", JSON.stringify([object]));
-      const process_array = JSON.parse(sessionStorage.global_process);
-      process_array.push({
-        link: "转派工单",
-        creatperson: `ADMIN ${this.$formatDate(new Date(), "YYYY-MM-DD")}`,
-        explain: "",
-      });
-      sessionStorage.setItem("global_process", JSON.stringify(process_array));
-      this.handleInit();
-      this.handleCancel("visible");
-      this.$message.success("转派成功");
+      console.log(this.edit_form, "prams");
+      // const object = {
+      //   ...JSON.parse(sessionStorage.global_data)[0],
+      //   department_status: "待审批",
+      // };
+      // sessionStorage.setItem("global_data", JSON.stringify([object]));
+      // const process_array = JSON.parse(sessionStorage.global_process);
+      // process_array.push({
+      //   link: "转派工单",
+      //   creatperson: `ADMIN ${this.$formatDate(new Date(), "YYYY-MM-DD")}`,
+      //   explain: "",
+      // });
+      // sessionStorage.setItem("global_process", JSON.stringify(process_array));
+      // this.handleInit();
+      // this.handleCancel("visible");
+      // this.$message.success("转派成功");
     },
     handleTurn(type) {
       this.handleCancel("approve_visible");
@@ -410,7 +413,24 @@ export default {
       this.handleCancel("approve_visible");
     },
     handleSubmit() {
-      this.$message.success("提交成功");
+      let reqdata = {
+        id: this.edit_form.id,
+        templateContent: this.edit_form.templateContent,
+      };
+      console.log(reqdata,'reqdata')
+      // 提交好了
+      // this.$http({
+      //   url: "/CMKIssued/CMKIssuedSubmit",
+      //   method: "post",
+      //   headers: {
+      //     "Content-Type": "application/json",
+      //   },
+      //   data: reqdata,
+      // }).then((res) => {
+      //   console.log(res);
+      //   this.$message.success("提交成功");
+      //   this.handleCancel("visible");
+      // });
     },
   },
 };

+ 39 - 30
src/pages/main/performance/issue.vue

@@ -32,7 +32,7 @@
           >
         </div>
       </div>
-      <analysis />
+      <sheet />
       <template v-slot:footer><div></div></template>
     </simple-dialog>
     <simple-dialog
@@ -53,18 +53,20 @@
 </template>
 
 <script>
-import analysis from "./analysis.vue";
+// import analysis from "./analysis.vue";
 import simpleForm from "./components/form.vue";
 import simpleTable from "./components/table.vue";
 import simpleDialog from "./components/dialog.vue";
 import simplePagination from "./components/pagination.vue";
+import sheet from "./components/sheet.vue"
 export default {
   components: {
-    analysis,
+    // analysis,
     simpleTable,
     simpleDialog,
     simpleForm,
     simplePagination,
+    sheet
   },
   data() {
     return {
@@ -128,12 +130,14 @@ export default {
           type: "click",
         },
       ],
-      receiver_table_list: [{
-          receiver:'接收人',
-          department:'科室',
-          date:'回复时间',
-          value:'2021.11.4 XXX 同意\n2021.11.4 XXX 同意'
-      }],
+      receiver_table_list: [
+        {
+          receiver: "接收人",
+          department: "科室",
+          date: "回复时间",
+          value: "2021.11.4 XXX 同意\n2021.11.4 XXX 同意",
+        },
+      ],
       receiver_table_config: [
         {
           label: "接收人",
@@ -150,7 +154,7 @@ export default {
         {
           label: "审批记录",
           props: "value",
-          type:'textarea'
+          type: "textarea",
         },
       ],
     };
@@ -167,13 +171,21 @@ export default {
       }).then((res) => {
         console.log(res);
         res.data = this.table_list;
-        this.table_list.push({
+        this.table_list.push(...[{
+          templateName: "模板名称",
+          precautions: "填报注意事项",
+          reason: "填报事由",
+          endTime: new Date(),
+          id: 23,
+          principalName: "接收人",
+        },{
           templateName: "模板名称",
           precautions: "填报注意事项",
           reason: "填报事由",
           endTime: new Date(),
+          id: 24,
           principalName: "接收人",
-        });
+        }]);
       });
       // this.table_loading = true;
       // const data = [];
@@ -219,24 +231,21 @@ export default {
     handleReset() {
       this.page = 1;
     },
-    handleWithdraw() {
-        console.log('aaaaaaaaaaaaa')
-      const array = [
-        {
-          ...JSON.parse(sessionStorage.global_data)[0],
-          issue_status: 0,
-        },
-      ];
-      sessionStorage.setItem("global_data", JSON.stringify(array));
-      const process_array = JSON.parse(sessionStorage.global_process);
-      process_array.push({
-        link: "撤回工单",
-        creatperson: `ADMIN ${this.$formatDate(new Date(), "YYYY-MM-DD")}`,
-        explain: "",
-      });
-      sessionStorage.setItem("global_process", JSON.stringify(process_array));
-      this.$message.success("撤回成功");
-      this.handleInit();
+    handleWithdraw({ id }) {
+      console.log({ id });
+      // this.$http({
+      //   url: "/CMKIssued/CMKDelIssuedById",
+      //   method: "post",
+      //   headers: {
+      //     "Content-Type": "application/json",
+      //   },
+      //   data: { id },
+      // }).then((res) => {
+      //   if (res) {
+      //     this.$message.success("撤回成功");
+      //     this.handleInit();
+      //   }
+      // });
     },
   },
   mounted() {

+ 86 - 190
src/pages/main/performance/mould.vue

@@ -12,8 +12,8 @@
                 :config="table_config"
                 :loading="table_loading"
                 :handle-row="table_handle_row"
-                @issue="handleVisible('issue')"
-                @detail="handleVisible('template')"
+                @issue="(params) => handleVisible('issue', params)"
+                @detail="(params) => handleVisible('template', params)"
                 @delete="handleDelete"
             ></simple-table>
             <simple-pagination
@@ -23,129 +23,51 @@
             ></simple-pagination>
         </div>
         <simple-dialog
-            title="查看模板"
-            fullscreen
-            @cancel="handleVisible('template')"
-            @confirm="handleVisible('template')"
-            :visible="template_visible"
-        >
-            <div class="flex-justify-between padding-right-20 padding-left-20">
-                <div>
-                    <el-button type="primary" @click="handleVisible('power')"
-                        >权限设置</el-button
-                    ><el-button type="primary">导出</el-button>
-                </div>
-                <div>
-                    <el-button @click="handleVisible('template')" type="primary"
-                        >返回</el-button
-                    >
-                </div>
-            </div>
-            <analysis />
-            <template v-slot:footer><div></div></template>
-        </simple-dialog>
-        <simple-dialog
             title="下发"
             width="500px"
             @cancel="handleVisible('issue')"
             @confirm="handleIssue"
             :visible="issue_visible"
         >
-            <el-form label-width="100px" :model="form">
+            <el-form label-width="100px" :model="issue_form">
                 <el-form-item label="填报事由">
-                    <el-input v-model="form.reason"></el-input>
+                    <el-input v-model="issue_form.reason"></el-input>
                 </el-form-item>
                 <el-form-item label="填报注意事项">
-                    <el-input v-model="form.note"></el-input>
+                    <el-input v-model="issue_form.precautions"></el-input>
                 </el-form-item>
                 <el-form-item label="截止时间">
-                    <el-date-picker v-model="form.date" type="date">
+                    <el-date-picker v-model="issue_form.endTime" type="date">
                     </el-date-picker>
                 </el-form-item>
-                <el-form-item label="">
-                    <el-upload
-                        drag
-                        action="https://jsonplaceholder.typicode.com/posts/"
-                        multiple
-                    >
-                        <i class="el-icon-upload"></i>
-                        <div>上传附件</div>
-                    </el-upload>
-                </el-form-item>
             </el-form>
         </simple-dialog>
         <simple-dialog
             fullscreen
             title="新增模板"
             :visible="add_visible"
-            :reload="reload"
             width="1200px"
             @confirm="handleVisible('add')"
             @cancel="handleVisible('add')"
         >
-            <el-form inline :model="form" label-width="100px">
-                <el-form-item label="绩效类型">
-                    <el-select v-model="form.type">
-                        <el-option label="部门绩效" value="部门绩效"></el-option
-                        ><el-option
-                            label="员工绩效"
-                            value="员工绩效"
-                        ></el-option> </el-select
-                ></el-form-item>
-                <el-form-item label="绩效分类">
-                    <el-select v-model="form.class">
-                        <el-option label="GS" value="GS"></el-option
-                        ><el-option
-                            label="KPI"
-                            value="KPI"
-                        ></el-option> </el-select
-                ></el-form-item>
-                <el-form-item label="">
-                    <el-button type="primary" @click="handleVisible('power')"
-                        >权限设置</el-button
-                    >
-                </el-form-item>
-            </el-form>
-            <simple-sheet />
+            <el-form inline :model="form" label-width="100px"> </el-form>
+            <simple-sheet v-if="add_visible" type="edit" />
             <template v-slot:footer><div></div></template>
         </simple-dialog>
         <simple-dialog
-            title="权限设置"
-            :visible="power_visible"
-            :reload="reload"
-            width="700px"
-            @confirm="handleVisible('power')"
-            @cancel="handleVisible('power')"
+            title="查看模板"
+            fullscreen
+            @cancel="handleVisible('template')"
+            @confirm="handleVisible('template')"
+            :visible="template_visible"
         >
-            <el-form :model="form" label-width="100px">
-                <el-form-item label="可编辑列"
-                    ><el-input v-model="form.editrows"
-                /></el-form-item>
-                <el-form-item label="权限规则">
-                    <el-select v-model="form.rule">
-                        <el-option
-                            v-for="item in ruleoptions"
-                            :key="item.value"
-                            :label="item.label"
-                            :value="item.value"
-                        ></el-option> </el-select
-                ></el-form-item>
-                <el-form-item label="负责人">
-                    <div>
-                        <el-cascader-panel
-                            v-model="form.charge"
-                            :options="charge_options"
-                            clearable
-                            @change="handleCascader"
-                        ></el-cascader-panel></div
-                ></el-form-item>
-            </el-form>
+            <simple-sheet v-if="template_visible" :id="template_id" />
+            <template v-slot:footer><div></div></template>
         </simple-dialog>
     </div>
 </template>
 
 <script>
-import analysis from "./analysis.vue";
 import simpleForm from "./components/form.vue";
 import simpleSheet from "./components/sheet.vue";
 import simpleTable from "./components/table.vue";
@@ -153,7 +75,6 @@ import simpleDialog from "./components/dialog.vue";
 import simplePagination from "./components/pagination.vue";
 export default {
     components: {
-        analysis,
         simpleTable,
         simpleDialog,
         simpleForm,
@@ -166,48 +87,21 @@ export default {
             rows: 10,
             total: 0,
             form: {},
-            reload: 0,
-            ruleoptions: [
-                {
-                    value: "按行号",
-                    label: "按行号",
-                },
-                {
-                    value: "按科室分配",
-                    label: "按科室分配",
-                },
-                {
-                    value: "按负责人分配",
-                    label: "按负责人分配",
-                },
-                {
-                    value: "所有人员",
-                    label: "",
-                },
-            ],
-            charge_options: [
-                {
-                    label: "科室名称1",
-                    value: "科室名称1",
-                    children: [
-                        {
-                            label: "负责人",
-                            value: "负责人",
-                            children: [{ label: "尹强", value: "尹强" }],
-                        },
-                    ],
-                },
-            ],
             add_visible: false,
-            power_visible: false,
+            // template
             template_visible: false,
+            template_id: null,
+            // issue
             issue_visible: false,
+            issue_form: {},
+            issue_id: null,
+            // table
             table_loading: false,
             table_search: {},
             table_form: [
                 {
                     label: "模板名称",
-                    props: "template_name",
+                    props: "templateName",
                     type: "input",
                 },
             ],
@@ -236,27 +130,24 @@ export default {
             table_config: [
                 {
                     label: "模板名称",
-                    props: "template_name",
+                    props: "templateName",
                 },
                 {
                     label: "配置时间",
-                    props: "template_date",
-                },
-                {
-                    label: "配置工号",
-                    props: "template_number",
+                    props: "updateTime",
                 },
                 {
-                    label: "模板分类",
-                    props: "template_class",
+                    label: "配置人员",
+                    props: "createId",
                 },
                 {
                     label: "模板状态",
-                    props: "template_status",
-                },
-                {
-                    label: "模板类型",
-                    props: "template_type",
+                    props: "status",
+                    type: "dictionary",
+                    dictionary: {
+                        0: "在用",
+                        1: "停用",
+                    },
                 },
             ],
         };
@@ -264,82 +155,87 @@ export default {
     methods: {
         async handleInit() {
             this.table_loading = true;
-            const data = [];
-            let index = 0;
-            while (index < 1) {
-                data.push(...JSON.parse(sessionStorage.global_data));
-                index = index + 1;
-            }
-            this.total = index;
-            this.table_list = data;
-            this.table_loading = false;
+            this.$http({
+                url: "/market/CMKFileTemplate/CMKFileTemplateList",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    page: this.page,
+                    pageSize: this.rows,
+                    templateName: this.table_search.templateName,
+                },
+            }).then(({ data: { count, data } }) => {
+                this.total = count;
+                this.table_list = data;
+                this.table_loading = false;
+            });
         },
-        handleSearch({ template_name }) {
-            this.table_search = { template_name };
+        handleSearch({ templateName }) {
+            this.table_search = { templateName };
             this.handleReset();
             this.handleInit();
         },
         handleAdd() {},
-        // 级联选择
-        handleCascader(data) {
-            console.log(data, "data");
-        },
-        handlePower() {},
         handleChange(page) {
             this.page = page;
             this.handleInit();
         },
-        handleVisible(props) {
+        handleVisible(props, params) {
             switch (props) {
                 case "add":
                     this.add_visible = !this.add_visible;
                     break;
-                case "power":
-                    this.power_visible = !this.power_visible;
-                    break;
                 case "template":
                     this.template_visible = !this.template_visible;
+                    this.template_id = params?.id;
                     break;
                 case "issue":
                     this.issue_visible = !this.issue_visible;
+                    this.issue_id = params ? params.id : null;
                     break;
             }
         },
         handleReset() {
             this.page = 1;
         },
-        handleDelete() {
-            sessionStorage.setItem("global_data", JSON.stringify([]));
-            sessionStorage.setItem("global_process", JSON.stringify([]));
-            this.$message.success("删除成功");
-            this.handleInit();
+        handleDelete({ id }) {
+            this.$http({
+                url: "/market/CMKFileTemplate/delCMKFileTemplateById",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    templateId: id,
+                },
+            }).then(() => {
+                this.$message.success("删除成功");
+                this.handleInit();
+            });
         },
         handleIssue() {
-            const array = [
-                {
-                    ...JSON.parse(sessionStorage.global_data)[0],
-                    department_status: "待处理",
-                    issue_status: 1,
-                    performance_type: "GS",
-                    reason: this.form.reason,
-                    note: this.form.note,
-                    date: this.form.date,
-                    receiver: `刘洁,李方岩,吴磊,孙震,赵洪松,孙川,韦琳娜`,
-                },
-            ];
-            sessionStorage.setItem("global_data", JSON.stringify(array));
-            const process_array = JSON.parse(sessionStorage.global_process);
-            process_array.push({
-                link: "发起工单",
-                creatperson: `ADMIN ${this.$formatDate(new Date(), "YYYY-MM-DD")}`,
-                explain: "",
+            this.$http({
+                url: "/market/CMKFileTemplate/issuedCMKFileTemplateById",
+                method: "post",
+                headers: {
+                    "Content-Type": "application/json",
+                },
+                data: {
+                    ...this.issue_form,
+                    endTime: this.$formatDate(
+                        this.issue_form.endTime,
+                        "YYYY-MM-DD"
+                    ),
+                    templateId: this.issue_id,
+                },
+            }).then(() => {
+                this.handleVisible("issue");
+                this.$message.success("下发成功");
+
+                this.handleInit();
             });
-            sessionStorage.setItem(
-                "global_process",
-                JSON.stringify(process_array)
-            );
-            this.$message.success("下发成功");
-            this.handleVisible("issue");
         },
     },
     mounted() {