Selaa lähdekoodia

邮件模板功能对接;邮件提醒界面,接口封装

wangyani 9 kuukautta sitten
vanhempi
sitoutus
cd55ad6233

+ 48 - 0
src/api/mes/email/notify.js

@@ -0,0 +1,48 @@
+import request from '@/utils/request'
+
+// 查看系统邮件提醒周期配置-分页/dev-api/iscs/notify/getIsMailNotifyConfigPage
+export function listIsMailNotifyConfigPage(query) {
+    return request({
+        url: '/iscs/notify/getIsMailNotifyConfigPage',
+        method: 'get',
+        params: query
+    })
+}
+
+
+// 新增系统邮件提醒周期配置 /dev-api/iscs/notify/insertIsMailNotifyConfig
+export function addIsMailNotifyConfig(data) {
+    return request({
+        url: '/iscs/notify/insertIsMailNotifyConfig',
+        method: 'post',
+        data: data
+    })
+}
+
+
+// 删除系统邮件提醒周期配置  ​/dev-api​/iscs​/notify​/deleteIsMailNotifyConfigByConfigIds
+export function deleteIsMailNotifyConfig(data) {
+    return request({
+        url: '/iscs/notify/deleteIsMailNotifyConfigByConfigIds?configIds=' + configIds,
+        method: 'post',
+    })
+}
+
+
+// 修改系统邮件提醒周期配置 /dev-api/iscs/notify/updateIsMailNotifyConfig
+export function updateIsMailNotifyConfig(data) {
+    return request({
+        url: '/iscs/notify/updateIsMailNotifyConfig',
+        method: 'post',
+        data: data
+    })
+}
+
+
+// 获取系统邮件提醒周期配置详细信息 /dev-api​/iscs​/notify​/selectIsMailNotifyConfigById
+export function getIsMailNotifyConfigById(configId) {
+    return request({
+        url: '/iscs/notify/selectIsMailNotifyConfigById?configId=' + configId,
+        method: 'get',
+    })
+}

+ 306 - 5
src/views/mes/email/emailNotify/index.vue

@@ -1,11 +1,312 @@
 <template>
+  <div class="app-container">
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      size="small"
+      :inline="true"
+      v-show="showSearch"
+    >
+      <el-form-item label="标题" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="请输入名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="内容" prop="content">
+        <el-input
+          v-model="queryParams.content"
+          placeholder="请输入内容"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          v-no-more-click
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索
+        </el-button>
+        <el-button
+          v-no-more-click
+          icon="el-icon-refresh"
+          size="mini"
+          @click="resetQuery"
+          >重置</el-button
+        >
+      </el-form-item>
+    </el-form>
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          v-no-more-click
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['iscs:template:add']"
+          >新增
+        </el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          v-no-more-click
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['iscs:blacklist:remove']"
+          >批量删除
+        </el-button>
+      </el-col>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
+    </el-row>
 
+    <el-table
+      v-if="refreshTable"
+      v-loading="loading"
+      :data="templatesList"
+      @selection-change="handleSelectionChange"
+    >
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column prop="name" label="提醒事项"></el-table-column>
+      <el-table-column prop="templateName" label="邮件模板"></el-table-column>
+      <el-table-column prop="reminderTime" label="提醒时长"></el-table-column>
+      <el-table-column
+        label="操作"
+        align="center"
+        class-name="small-padding fixed-width"
+      >
+        <template slot-scope="scope">
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['iscs:template:edit']"
+            >编辑
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.current"
+      :limit.sync="queryParams.size"
+      @pagination="getList"
+    />
+    <!-- 添加或修改对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="470px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="邮件模板编号" prop="templateCode">
+          <el-input
+            v-model="form.templateCode"
+            placeholder="请输入邮件模板名称"
+          />
+        </el-form-item>
+        <el-form-item label="提醒事项" prop="name">
+          <el-input v-model="form.name" placeholder="请输入邮件模板名称" />
+        </el-form-item>
+        <el-form-item label="邮件模板内容" prop="content">
+          <el-input
+            type="textarea"
+            :rows="10"
+            v-model="form.content"
+            placeholder="请输入邮件模板名称"
+          />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button v-no-more-click type="primary" @click="submitForm"
+          >确 定</el-button
+        >
+        <el-button v-no-more-click @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
 </template>
+
 <script>
+import {
+  listIsMailNotifyConfigPage,
+  addIsMailNotifyConfig,
+  deleteIsMailNotifyConfig,
+  updateIsMailNotifyConfig,
+  getIsMailNotifyConfigById,
+} from "@/api/mes/email/notify";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { genCode } from "@/api/system/autocode/rule";
+import Template from "@/views/print/printtemplate/list.vue";
+
 export default {
-  name: 'index'
-}
-</script>
-<style scoped lang="scss">
+  name: "Dept",
+  dicts: ["sys_normal_disable", "sop_type"],
+  components: { Template, Treeselect },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      //自动生成编码
+      autoGenFlag: false,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 选中数组
+      codes: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 邮件模板列表
+      templatesList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+
+      // 重新渲染表格状态
+      refreshTable: true,
+      // 查询参数
+      queryParams: {
+        current: 1,
+        size: 10,
+        name: "",
+        content: "",
+      },
+      isEdit: false,
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        templateCode: [
+          { required: true, message: "邮件模板编号不能为空", trigger: "blur" },
+        ],
+        name: [
+          { required: true, message: "邮件模板名称不能为空", trigger: "blur" },
+        ],
+        content: [
+          { required: true, message: "邮件模板内容不能为空", trigger: "blur" },
+        ],
+      },
+    };
+  },
+  created() {
+    this.getList();
+  },
 
-</style>
+  methods: {
+    /** 查询部门列表 */
+    getList() {
+      this.loading = true;
+      listIsMailNotifyConfigPage(this.queryParams).then((response) => {
+        debugger;
+        this.templatesList = response.data.records;
+        this.total = response.data.total;
+        this.loading = false;
+        console.log(response.data.records, "列表内容");
+      });
+    },
+
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        sopId: undefined,
+        parentId: undefined,
+        sopName: undefined,
+      };
+      this.autoGenFlag = false;
+      this.resetForm("form");
+    },
+
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.current = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.queryParams.name = "";
+      this.queryParams.content = "";
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.codes = selection.map((item) => item.templateCode);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.isEdit = false;
+      this.title = "添加邮件模板";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      this.isEdit = true;
+      getEmailTemplatesInfo(row.templateCode).then((response) => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改邮件模板";
+      });
+    },
+    /** 提交按钮 */
+    submitForm: function () {
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          if (this.isEdit) {
+            updateIsMailNotifyConfig(this.form).then((response) => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addIsMailNotifyConfig(this.form).then((response) => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const templateCodes = row.templateCode || this.codes;
+      this.$modal
+        .confirm('是否确认删除名称为"' + templateCodes + '"的数据项?')
+        .then(function () {
+          return deleteIsMailNotifyConfig(templateCodes);
+        })
+        .then(() => {
+          this.getList();
+          this.$modal.msgSuccess("删除成功");
+        })
+        .catch(() => {});
+    },
+  },
+};
+</script>

+ 193 - 153
src/views/mes/email/emailTemplates/index.vue

@@ -1,91 +1,129 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
-
-      <el-form-item label="名称" prop="sopName">
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      size="small"
+      :inline="true"
+      v-show="showSearch"
+    >
+      <el-form-item label="名称" prop="name">
         <el-input
-          v-model="queryParams.sopName"
+          v-model="queryParams.name"
           placeholder="请输入名称"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="内容" prop="sopCode">
+      <el-form-item label="内容" prop="content">
         <el-input
-          v-model="queryParams.sopCode"
+          v-model="queryParams.content"
           placeholder="请输入内容"
           clearable
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
       <el-form-item>
-        <el-button v-no-more-click type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
+        <el-button
+          v-no-more-click
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索
         </el-button>
-        <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          v-no-more-click
+          icon="el-icon-refresh"
+          size="mini"
+          @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
     </el-form>
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button v-no-more-click
-                   type="primary"
-                   plain
-                   icon="el-icon-plus"
-                   size="mini"
-                   @click="handleAdd"
-                   v-hasPermi="['iscs:template:add']"
-        >新增
+        <el-button
+          v-no-more-click
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['iscs:template:add']"
+          >新增
         </el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button v-no-more-click
-                   type="info"
-                   plain
-                   icon="el-icon-sort"
-                   size="mini"
-                   @click="toggleExpandAll"
-        >展开/折叠
+        <el-button
+          v-no-more-click
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['iscs:blacklist:remove']"
+          >批量删除
         </el-button>
       </el-col>
-      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar
+        :showSearch.sync="showSearch"
+        @queryTable="getList"
+      ></right-toolbar>
     </el-row>
 
     <el-table
       v-if="refreshTable"
       v-loading="loading"
-      :data="deptList"
+      :data="templatesList"
+      @selection-change="handleSelectionChange"
     >
-      <el-table-column prop="templateCode" label="邮件模板编号"></el-table-column>
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column
+        prop="templateCode"
+        label="邮件模板编号"
+      ></el-table-column>
       <el-table-column prop="name" label="邮件模板名称"></el-table-column>
       <el-table-column prop="content" label="内容">
         <template slot-scope="scope">
           <el-button type="text" @click="check(scope.row)">查看</el-button>
         </template>
       </el-table-column>
-      <el-table-column label="添加时间" align="center" prop="createTime" width="200">
+      <el-table-column
+        label="添加时间"
+        align="center"
+        prop="createTime"
+        width="200"
+      >
         <template slot-scope="scope">
           <span>{{ scope.row.createTime }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column
+        label="操作"
+        align="center"
+        class-name="small-padding fixed-width"
+      >
         <template slot-scope="scope">
-          <el-button v-no-more-click
-                     size="mini"
-                     type="text"
-                     icon="el-icon-edit"
-                     @click="handleUpdate(scope.row)"
-                     v-hasPermi="['iscs:template:edit']"
-          >修改
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['iscs:template:edit']"
+            >编辑
           </el-button>
-          <el-button v-no-more-click
-
-                     size="mini"
-                     type="text"
-                     icon="el-icon-delete"
-                     @click="handleDelete(scope.row)"
-                     v-hasPermi="['iscs:template:remove']"
-          >删除
+          <el-button
+            v-no-more-click
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['iscs:template:remove']"
+            >删除
           </el-button>
-
         </template>
       </el-table-column>
     </el-table>
@@ -99,19 +137,31 @@
     <!-- 添加或修改部门对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="470px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="邮件模板编号" prop="templateCode">
+          <el-input
+            v-model="form.templateCode"
+            placeholder="请输入邮件模板名称"
+          />
+        </el-form-item>
         <el-form-item label="邮件模板名称" prop="name">
-          <el-input v-model="form.name" placeholder="请输入邮件模板名称"/>
+          <el-input v-model="form.name" placeholder="请输入邮件模板名称" />
         </el-form-item>
         <el-form-item label="邮件模板内容" prop="content">
-          <el-input type="textarea" :rows="10" v-model="form.content" placeholder="请输入邮件模板名称"/>
+          <el-input
+            type="textarea"
+            :rows="10"
+            v-model="form.content"
+            placeholder="请输入邮件模板名称"
+          />
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button v-no-more-click type="primary" @click="submitForm">确 定</el-button>
+        <el-button v-no-more-click type="primary" @click="submitForm"
+          >确 定</el-button
+        >
         <el-button v-no-more-click @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-
   </div>
 </template>
 
@@ -121,16 +171,16 @@ import {
   getEmailTemplatesInfo,
   addEmailTemplates,
   updateEmailTemplates,
-  delEmailTemplates
-} from '@/api/mes/email/templates'
-import Treeselect from '@riophae/vue-treeselect'
-import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-import { genCode } from '@/api/system/autocode/rule'
-import Template from '@/views/print/printtemplate/list.vue'
+  delEmailTemplates,
+} from "@/api/mes/email/templates";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { genCode } from "@/api/system/autocode/rule";
+import Template from "@/views/print/printtemplate/list.vue";
 
 export default {
-  name: 'Dept',
-  dicts: ['sys_normal_disable', 'sop_type'],
+  name: "Dept",
+  dicts: ["sys_normal_disable", "sop_type"],
   components: { Template, Treeselect },
   data() {
     return {
@@ -140,159 +190,149 @@ export default {
       autoGenFlag: false,
       // 显示搜索条件
       showSearch: true,
-      isEditing: false,//添加一个标识符
       // 总条数
       total: 0,
-      // 表格树数据
-      deptList: [],
+      // 选中数组
+      codes: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 邮件模板列表
+      templatesList: [],
       // 弹出层标题
-      title: '',
+      title: "",
       // 是否显示弹出层
       open: false,
-      // 是否展开,默认全部展开
-      isExpandAll: true,
+
       // 重新渲染表格状态
       refreshTable: true,
       // 查询参数
       queryParams: {
         current: 1,
-        size: 10
-
+        size: 10,
+        name: "",
+        content: "",
       },
-
+      isEdit: false,
       // 表单参数
-      form: {
-        machineryId: ''
-      },
+      form: {},
       // 表单校验
       rules: {
-        sopCode: [
-          { required: true, message: 'SOP编码不能为空', trigger: 'blur' }
-        ],
-        sopName: [
-          { required: true, message: 'SOP名称不能为空', trigger: 'blur' }
+        templateCode: [
+          { required: true, message: "邮件模板编号不能为空", trigger: "blur" },
         ],
-        workstationId: [
-          { required: true, message: '岗位不能为空', trigger: 'blur' }
+        name: [
+          { required: true, message: "邮件模板名称不能为空", trigger: "blur" },
         ],
-        lotoId: [
-          { required: true, message: '锁定站不能为空', trigger: 'blur' }
+        content: [
+          { required: true, message: "邮件模板内容不能为空", trigger: "blur" },
         ],
-        machineryId: [
-          { required: true, message: '设备/工艺不能为空', trigger: 'blur' }
-        ]
-      }
-
-    }
+      },
+    };
   },
   created() {
-    this.getList()
-
+    this.getList();
   },
 
   methods: {
     /** 查询部门列表 */
     getList() {
-      this.loading = true
-      listEmailTemplates(this.queryParams).then(response => {
+      this.loading = true;
+      listEmailTemplates(this.queryParams).then((response) => {
         debugger;
-        this.deptList = response.data.records
-        this.total = response.data.total
-        this.loading = false
-      })
-
+        this.templatesList = response.data.records;
+        this.total = response.data.total;
+        this.loading = false;
+        console.log(response.data.records, "列表内容");
+      });
     },
 
     // 取消按钮
     cancel() {
-      this.open = false
-      this.reset()
+      this.open = false;
+      this.reset();
     },
     // 表单重置
     reset() {
       this.form = {
         sopId: undefined,
         parentId: undefined,
-        sopName: undefined
-      }
-      this.autoGenFlag = false
-      this.resetForm('form')
+        sopName: undefined,
+      };
+      this.autoGenFlag = false;
+      this.resetForm("form");
     },
 
-
     /** 搜索按钮操作 */
     handleQuery() {
-      this.getList()
+      this.queryParams.current = 1;
+      this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
-      this.resetForm('queryForm')
-      this.queryParams.sopName = ''
-      this.handleQuery()
+      this.queryParams.name = "";
+      this.queryParams.content = "";
+      this.resetForm("queryForm");
+      this.handleQuery();
     },
-
-    /** 展开/折叠操作 */
-    toggleExpandAll() {
-      this.refreshTable = false
-      this.isExpandAll = !this.isExpandAll
-      this.$nextTick(() => {
-        this.refreshTable = true
-      })
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.codes = selection.map((item) => item.templateCode);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
     },
     /** 新增按钮操作 */
     handleAdd() {
-      this.reset()
-      this.open = true
-      this.title = '添加邮件模板'
-
+      this.reset();
+      this.open = true;
+      this.isEdit = false;
+      this.title = "添加邮件模板";
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      this.reset()
-      this.isEditing = true
-      getEmailTemplatesInfo(row.templateCode).then(response => {
-        this.form = response.data
-        this.open = true
-        setTimeout(() => {
-          this.isEditing = false
-        }, 1000)
-        this.title = '修改邮件模板'
-
-      })
+      this.reset();
+      this.isEdit = true;
+      getEmailTemplatesInfo(row.templateCode).then((response) => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改邮件模板";
+      });
     },
     /** 提交按钮 */
-    submitForm: function() {
-      this.$refs['form'].validate(valid => {
+    submitForm: function () {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
-          if (this.form.templateCode != undefined) {
-            updateEmailTemplates(this.form).then(response => {
-              this.$modal.msgSuccess('修改成功')
-              this.open = false
-
-              this.getList()
-            })
+          if (this.isEdit) {
+            updateEmailTemplates(this.form).then((response) => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
           } else {
-            addEmailTemplates(this.form).then(response => {
-              this.$modal.msgSuccess('新增成功')
-              this.open = false
-              this.getList()
-            })
+            addEmailTemplates(this.form).then((response) => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
           }
         }
-      })
+      });
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      this.$modal.confirm('是否确认删除名称为"' + row.sopName + '"的数据项?').then(function() {
-        return delEmailTemplates(row.sopId)
-      }).then(() => {
-        this.getList()
-        this.$modal.msgSuccess('删除成功')
-      }).catch(() => {
-      })
-    }
-
-  }
-
-}
+      const templateCodes = row.templateCode || this.codes;
+      this.$modal
+        .confirm('是否确认删除名称为"' + templateCodes + '"的数据项?')
+        .then(function () {
+          return delEmailTemplates(templateCodes);
+        })
+        .then(() => {
+          this.getList();
+          this.$modal.msgSuccess("删除成功");
+        })
+        .catch(() => {});
+    },
+  },
+};
 </script>