index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. >
  10. <el-form-item label="邮件模板名称" prop="templateName">
  11. <el-input
  12. v-model="queryParams.templateName"
  13. placeholder="请输入邮件模板名称"
  14. clearable
  15. @keyup.enter.native="handleQuery"
  16. />
  17. </el-form-item>
  18. <el-form-item label="邮件模板标题" prop="templateTitle">
  19. <el-input
  20. v-model="queryParams.templateTitle"
  21. placeholder="请输入邮件模板标题"
  22. clearable
  23. @keyup.enter.native="handleQuery"
  24. />
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button
  28. v-no-more-click
  29. type="primary"
  30. icon="el-icon-search"
  31. size="mini"
  32. @click="handleQuery"
  33. >搜索
  34. </el-button>
  35. <el-button
  36. v-no-more-click
  37. icon="el-icon-refresh"
  38. size="mini"
  39. @click="resetQuery"
  40. >重置</el-button
  41. >
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. v-no-more-click
  48. type="primary"
  49. plain
  50. icon="el-icon-plus"
  51. size="mini"
  52. @click="handleAdd"
  53. v-hasPermi="['iscs:template:add']"
  54. >新增
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. v-no-more-click
  60. type="danger"
  61. plain
  62. icon="el-icon-delete"
  63. size="mini"
  64. :disabled="multiple"
  65. @click="handleDelete"
  66. v-hasPermi="['iscs:template:remove']"
  67. >批量删除
  68. </el-button>
  69. </el-col>
  70. <right-toolbar
  71. :showSearch.sync="showSearch"
  72. @queryTable="getList"
  73. ></right-toolbar>
  74. </el-row>
  75. <el-table
  76. v-if="refreshTable"
  77. v-loading="loading"
  78. :data="templatesList"
  79. @selection-change="handleSelectionChange"
  80. >
  81. <el-table-column type="selection" width="55" align="center" />
  82. <el-table-column
  83. prop="templateCode"
  84. label="邮件模板编号"
  85. ></el-table-column>
  86. <el-table-column prop="templateName" label="邮件模板名称"></el-table-column>
  87. <el-table-column prop="templateTitle" label="邮件模板标题"></el-table-column>
  88. <el-table-column prop="templateContent" label="内容">
  89. <template slot-scope="scope">
  90. <el-button type="text" @click="check(scope.row)">查看</el-button>
  91. </template>
  92. </el-table-column>
  93. <el-table-column
  94. label="添加时间"
  95. align="center"
  96. prop="createTime"
  97. width="200"
  98. >
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.createTime }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. label="操作"
  105. align="center"
  106. class-name="small-padding fixed-width"
  107. >
  108. <template slot-scope="scope">
  109. <el-button
  110. v-no-more-click
  111. size="mini"
  112. type="text"
  113. icon="el-icon-edit"
  114. @click="handleUpdate(scope.row)"
  115. v-hasPermi="['iscs:template:edit']"
  116. >编辑
  117. </el-button>
  118. <el-button
  119. v-no-more-click
  120. size="mini"
  121. type="text"
  122. icon="el-icon-delete"
  123. @click="handleDelete(scope.row)"
  124. v-hasPermi="['iscs:template:remove']"
  125. >删除
  126. </el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <pagination
  131. v-show="total > 0"
  132. :total="total"
  133. :page.sync="queryParams.current"
  134. :limit.sync="queryParams.size"
  135. @pagination="getList"
  136. />
  137. <!-- 添加或修改邮件模板对话框 -->
  138. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  139. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  140. <el-form-item label="邮件模板编号" prop="templateCode">
  141. <el-input
  142. :disabled="isEdit"
  143. v-model="form.templateCode"
  144. placeholder="请输入邮件模板编号"
  145. />
  146. </el-form-item>
  147. <el-form-item label="邮件模板名称" prop="templateName">
  148. <el-input v-model="form.templateName" placeholder="请输入邮件模板名称" />
  149. </el-form-item>
  150. <el-form-item label="邮件模板标题" prop="templateTitle">
  151. <el-input v-model="form.templateTitle" placeholder="请输入邮件模板标题" />
  152. </el-form-item>
  153. <el-form-item label="邮件模板内容" prop="templateContent">
  154. <el-input
  155. type="textarea"
  156. :rows="20"
  157. v-model="form.templateContent"
  158. placeholder="请输入邮件模板内容"
  159. />
  160. </el-form-item>
  161. </el-form>
  162. <div slot="footer" class="dialog-footer">
  163. <el-button v-no-more-click type="primary" @click="submitForm"
  164. >确 定</el-button
  165. >
  166. <el-button v-no-more-click @click="cancel">取 消</el-button>
  167. </div>
  168. </el-dialog>
  169. <el-dialog title="内容查看" :visible.sync="openCheck" width="600px" append-to-body>
  170. <el-form ref="form" :model="form" :rules="rules" >
  171. <el-input type="textarea" autosize v-model="form.templateContent" ></el-input>
  172. </el-form>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button v-no-more-click @click="cancel">关 闭</el-button>
  175. </div>
  176. </el-dialog>
  177. </div>
  178. </template>
  179. <script>
  180. import {
  181. listEmailTemplates,
  182. getEmailTemplatesInfo,
  183. addEmailTemplates,
  184. updateEmailTemplates,
  185. delEmailTemplates,
  186. } from "@/api/mes/email/templates";
  187. import Treeselect from "@riophae/vue-treeselect";
  188. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  189. import { genCode } from "@/api/system/autocode/rule";
  190. import Template from "@/views/print/printtemplate/list.vue";
  191. export default {
  192. name: "Dept",
  193. dicts: ["sys_normal_disable", "sop_type"],
  194. components: { Template, Treeselect },
  195. data() {
  196. return {
  197. // 遮罩层
  198. loading: true,
  199. //自动生成编码
  200. autoGenFlag: false,
  201. // 显示搜索条件
  202. showSearch: true,
  203. // 总条数
  204. total: 0,
  205. // 选中数组
  206. codes: [],
  207. // 非单个禁用
  208. single: true,
  209. // 非多个禁用
  210. multiple: true,
  211. // 邮件模板列表
  212. templatesList: [],
  213. // 弹出层标题
  214. title: "",
  215. // 是否显示弹出层
  216. open: false,
  217. openCheck:false,//内容查看
  218. // 重新渲染表格状态
  219. refreshTable: true,
  220. // 查询参数
  221. queryParams: {
  222. current: 1,
  223. size: 10,
  224. templateName: "",
  225. templateTitle: "",
  226. },
  227. isEdit: false,
  228. // 表单参数
  229. form: {},
  230. // 表单校验
  231. rules: {
  232. templateCode: [
  233. { required: true, message: "邮件模板编号不能为空", trigger: "blur" },
  234. ],
  235. name: [
  236. { required: true, message: "邮件模板名称不能为空", trigger: "blur" },
  237. ],
  238. content: [
  239. { required: true, message: "邮件模板内容不能为空", trigger: "blur" },
  240. ],
  241. },
  242. };
  243. },
  244. created() {
  245. this.getList();
  246. },
  247. methods: {
  248. /** 查询部门列表 */
  249. getList() {
  250. this.loading = true;
  251. listEmailTemplates(this.queryParams).then((response) => {
  252. debugger;
  253. this.templatesList = response.data.records;
  254. this.total = response.data.total;
  255. this.loading = false;
  256. console.log(response.data.records, "列表内容");
  257. });
  258. },
  259. // 取消按钮
  260. cancel() {
  261. this.open = false;
  262. this.openCheck = false;
  263. this.reset();
  264. },
  265. // 表单重置
  266. reset() {
  267. this.form = {
  268. templateName: undefined,
  269. templateTitle: undefined,
  270. templateContent: undefined,
  271. };
  272. this.autoGenFlag = false;
  273. this.resetForm("form");
  274. },
  275. /** 搜索按钮操作 */
  276. handleQuery() {
  277. this.queryParams.current = 1;
  278. this.getList();
  279. },
  280. /** 重置按钮操作 */
  281. resetQuery() {
  282. this.queryParams.templateName = "";
  283. this.queryParams.templateTitle = "";
  284. this.resetForm("queryForm");
  285. this.handleQuery();
  286. },
  287. // 多选框选中数据
  288. handleSelectionChange(selection) {
  289. this.codes = selection.map((item) => item.templateId);
  290. this.single = selection.length !== 1;
  291. this.multiple = !selection.length;
  292. },
  293. /** 新增按钮操作 */
  294. handleAdd() {
  295. this.reset();
  296. this.open = true;
  297. this.isEdit = false;
  298. this.title = "添加邮件模板";
  299. },
  300. /** 修改按钮操作 */
  301. handleUpdate(row) {
  302. this.reset();
  303. this.isEdit = true;
  304. console.log(row,'row');
  305. getEmailTemplatesInfo(row.templateId).then((response) => {
  306. this.form = response.data;
  307. this.open = true;
  308. this.title = "修改邮件模板";
  309. });
  310. },
  311. /** 提交按钮 */
  312. submitForm: function () {
  313. this.$refs["form"].validate((valid) => {
  314. if (valid) {
  315. if (this.isEdit) {
  316. updateEmailTemplates(this.form).then((response) => {
  317. this.$modal.msgSuccess("修改成功");
  318. this.open = false;
  319. this.getList();
  320. });
  321. } else {
  322. addEmailTemplates(this.form).then((response) => {
  323. this.$modal.msgSuccess("新增成功");
  324. this.open = false;
  325. this.getList();
  326. });
  327. }
  328. }
  329. });
  330. },
  331. /* 查看 */
  332. check(row){
  333. console.log(row);
  334. this.openCheck = true;
  335. this.form = row;
  336. },
  337. /** 删除按钮操作 */
  338. handleDelete(row) {
  339. const templateIds = row.templateId || this.codes;
  340. this.$modal
  341. .confirm('是否确认删除名称为"' + templateIds + '"的数据项?')
  342. .then(function () {
  343. return delEmailTemplates(templateIds);
  344. })
  345. .then(() => {
  346. this.getList();
  347. this.$modal.msgSuccess("删除成功");
  348. })
  349. .catch(() => {});
  350. },
  351. },
  352. };
  353. </script>