index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <!--证书管理-->
  2. <template>
  3. <div class="app-container certificate">
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" class="form-box">
  5. <el-form-item label="证书名称" prop="certTitle">
  6. <el-input
  7. v-model="queryParams.certTitle"
  8. placeholder="请输入证书名称"
  9. clearable
  10. size="small"
  11. />
  12. </el-form-item>
  13. <el-form-item style="float: right;">
  14. <el-col :span="1.5" style="margin-right:20px;">
  15. <p class="add-button-one-120"
  16. @click="handleAdd"
  17. v-hasPermi="['exam:certificate:add']"
  18. ><i class="el-icon-plus"></i>新增证书</p>
  19. </el-col>
  20. </el-form-item>
  21. <el-form-item>
  22. <p class="inquire-button-one" @click="handleQuery">查询</p>
  23. <p class="reset-button-one" @click="resetQuery">重置</p>
  24. </el-form-item>
  25. </el-form>
  26. <el-table v-loading="loading" border :data="certificateList" @selection-change="handleSelectionChange">
  27. <el-table-column label="证书名称" align="left" prop="certTitle"/>
  28. <!--<el-table-column label="学科类别" align="left" prop="certType" >-->
  29. <!--<template slot-scope="scope">-->
  30. <!--          <p v-for="(item,index) in subClassOptions" :key="index" v-if="scope.row.certType==item.dictValue">{{item.dictLabel}}</p >-->
  31. <!--        </template>-->
  32. <!--</el-table-column>-->
  33. <el-table-column label="证书有效期(月)" align="left" prop="certValidity" />
  34. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  35. <template slot-scope="scope">
  36. <div class="table-button-box">
  37. <p class="table-button-null"></p>
  38. <p class="table-button-p"
  39. @click="handleUpdate(scope.row)"
  40. v-hasPermiAnd="['laboratory:safe_book:edit','exam:certificate:edit']"
  41. >编辑</p>
  42. <p class="table-button-p"
  43. @click="handleDelete(scope.row)"
  44. v-hasPermi="['exam:certificate:remove']"
  45. >删除</p>
  46. <p class="table-button-null"></p>
  47. </div>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <pagination :page-sizes="[20, 30, 40, 50]"
  52. v-show="total>0"
  53. :total="total"
  54. layout="total, prev, pager, next, sizes, jumper"
  55. :page.sync="queryParams.pageNum"
  56. :limit.sync="queryParams.pageSize"
  57. @pagination="getList"
  58. />
  59. <!-- 添加或修改证书管理对话框 -->
  60. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body class="cartifcate-dialog" :close-on-click-modal="false">
  61. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  62. <el-form-item label="证书名称" prop="certTitle">
  63. <el-input v-model="form.certTitle" placeholder="请输入证书名称" maxlength="20"/>
  64. </el-form-item>
  65. <!--<el-form-item label="封面" prop="certUrl">-->
  66. <!--<el-upload-->
  67. <!--class="avatar-uploader"-->
  68. <!--action="https://jsonplaceholder.typicode.com/posts/"-->
  69. <!--:show-file-list="false"-->
  70. <!--:on-success="handleAvatarSuccess"-->
  71. <!--:before-upload="beforeAvatarUpload">-->
  72. <!--<img v-if="imageUrl" :src="imageUrl" class="avatar">-->
  73. <!--<i v-else class="el-icon-plus avatar-uploader-icon"></i>-->
  74. <!--</el-upload>-->
  75. <!--&lt;!&ndash;<el-input v-model="form.certUrl" placeholder="请输入证书上传的图片" />&ndash;&gt;-->
  76. <!--</el-form-item>-->
  77. <el-form-item label="封面" prop="certUrl">
  78. <el-upload
  79. class="certificate-avatar-uploader"
  80. :action="uploadImgUrl"
  81. :show-file-list="false"
  82. accept="image/jpeg,image/gif,image/png"
  83. :on-success="handleAvatarSuccess"
  84. :headers="headers"
  85. :before-upload="beforeAvatarUpload">
  86. <img v-if="form.certUrl" :src="form.certUrl" class="avatar">
  87. <i v-if="!form.certUrl" class="el-icon-plus avatar-uploader-icon"></i>
  88. </el-upload>
  89. </el-form-item>
  90. <!--<el-form-item label="学科类别" prop="certType">-->
  91. <!--<el-select v-model="form.certType" placeholder="请选择学科类别">-->
  92. <!--<el-option-->
  93. <!--v-for="dict in subClassOptions"-->
  94. <!--:key="dict.dictValue"-->
  95. <!--:label="dict.dictLabel"-->
  96. <!--:value="dict.dictValue">-->
  97. <!--</el-option>-->
  98. <!--</el-select>-->
  99. <!--</el-form-item>-->
  100. <el-form-item label="有效期" prop="certValidity">
  101. <!-- @change="handleChange"-->
  102. <el-input-number v-model="form.certValidity" :min="1" :max="24" label="输入有效期"></el-input-number><span style="margin-left:20px;font-size:16px;">(月)</span>
  103. </el-form-item>
  104. <!--
  105. 有效期为 一个月/三个月/半年/一年
  106. -->
  107. </el-form>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button @click="cancel">取 消</el-button>
  110. <el-button type="primary" @click="submitForm">确 定</el-button>
  111. </div>
  112. </el-dialog>
  113. </div>
  114. </template>
  115. <script>
  116. import { listCertificate, getCertificate, delCertificate, addCertificate, updateCertificate, listByCertType,updateTrain } from "@/api/exam/certificate";
  117. import { getToken } from "@/utils/auth";
  118. export default {
  119. name: "Certificate",
  120. data() {
  121. return {
  122. tableButtonType:this.hasPermiDom(['laboratory:safe_book:edit','exam:certificate:edit','exam:certificate:remove']),
  123. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  124. headers: {
  125. Authorization: "Bearer " + getToken(),
  126. },
  127. // 遮罩层
  128. loading: true,
  129. // 选中数组
  130. ids: [],
  131. // 非单个禁用
  132. single: true,
  133. // 非多个禁用
  134. multiple: true,
  135. // 显示搜索条件
  136. showSearch: true,
  137. // 总条数
  138. total: 0,
  139. // 证书管理表格数据
  140. certificateList: [],
  141. // 弹出层标题
  142. title: "",
  143. // 是否显示弹出层
  144. open: false,
  145. subClassOptions: "",
  146. // 查询参数
  147. queryParams: {
  148. pageNum: 1,
  149. pageSize:20,
  150. certTitle: null,
  151. certType: null,
  152. certUrl: null,
  153. certValidity: null,
  154. certValidityUnit: null,
  155. deptId: null,
  156. deptName: null,
  157. userId: null,
  158. },
  159. // 表单参数
  160. form: {
  161. certValidity: 1,
  162. certType: 1
  163. },
  164. // 表单校验
  165. rules: {
  166. certTitle: [
  167. { required: true, message: "请输入证书名称", trigger: "blur" },
  168. { required: true, message: "请输入播放文字", validator: this.spaceJudgment, trigger: "blur" }
  169. ],
  170. certType: [
  171. { required: true, message: "请选择学科类别", trigger: "blur" }
  172. ],
  173. certUrl: [
  174. { required: true, message: "请上传封面照片", trigger: "blur" }
  175. ],
  176. certValidity: [
  177. { required: true, message: "输入有效期", trigger: "blur" },
  178. { required: true, message: "输入有效期", validator: this.spaceJudgment, trigger: "blur" }
  179. ]
  180. },
  181. imageUrl:"",
  182. };
  183. },
  184. created() {
  185. this.getList(),
  186. this.getDicts("subject_class").then(response => {
  187. this.subClassOptions = response.data;
  188. })
  189. },
  190. methods: {
  191. //上传
  192. handleAvatarSuccess(res, file) {
  193. // this.imageUrl = URL.createObjectURL(file.raw);
  194. console.log(res.data.url);
  195. this.form.certUrl = res.data.url;
  196. this.$forceUpdate()
  197. },
  198. beforeAvatarUpload(file) {
  199. let type = false;
  200. console.log('file',file);
  201. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  202. type = true;
  203. }else{
  204. this.$message.error('只能上传png/jpeg/gif格式图片');
  205. type = false;
  206. }
  207. return type;
  208. },
  209. /** 查询证书管理列表 */
  210. getList() {
  211. this.loading = true;
  212. listCertificate(this.queryParams).then(response => {
  213. this.certificateList = response.rows;
  214. this.total = response.total;
  215. this.loading = false;
  216. });
  217. },
  218. // 取消按钮
  219. cancel() {
  220. this.open = false;
  221. this.reset();
  222. },
  223. // 表单重置
  224. reset() {
  225. this.form = {
  226. id: null,
  227. certTitle: null,
  228. certType: null,
  229. certUrl: null,
  230. certValidity: null,
  231. certValidityUnit: null,
  232. deptId: null,
  233. deptName: null,
  234. userId: null,
  235. createBy: null,
  236. createTime: null,
  237. updateBy: null,
  238. updateTime: null,
  239. remark: null
  240. };
  241. this.imageUrl = "";
  242. this.resetForm("form");
  243. },
  244. /** 搜索按钮操作 */
  245. handleQuery() {
  246. this.queryParams.pageNum = 1;
  247. this.getList();
  248. },
  249. /** 重置按钮操作 */
  250. resetQuery() {
  251. this.resetForm("queryForm");
  252. this.handleQuery();
  253. },
  254. // 多选框选中数据
  255. handleSelectionChange(selection) {
  256. this.ids = selection.map(item => item.id)
  257. this.single = selection.length!==1
  258. this.multiple = !selection.length
  259. },
  260. /** 新增按钮操作 */
  261. handleAdd() {
  262. this.reset();
  263. this.open = true;
  264. this.title = "添加证书管理";
  265. },
  266. /** 修改按钮操作 */
  267. handleUpdate(row) {
  268. this.reset();
  269. const id = row.id || this.ids
  270. getCertificate(id).then(response => {
  271. this.form = response.data;
  272. this.form.certType = ""+response.data.certType;
  273. this.open = true;
  274. this.title = "修改证书管理";
  275. });
  276. },
  277. /** 提交按钮 */
  278. submitForm() {
  279. this.$refs["form"].validate(valid => {
  280. if (valid) {
  281. if (this.form.id != null) {
  282. updateCertificate(this.form).then(response => {
  283. this.msgSuccess("修改成功");
  284. this.open = false;
  285. this.getList();
  286. });
  287. } else {
  288. addCertificate(this.form).then(response => {
  289. this.msgSuccess("新增成功");
  290. this.open = false;
  291. this.getList();
  292. });
  293. }
  294. }
  295. });
  296. },
  297. /** 删除按钮操作 */
  298. handleDelete(row) {
  299. const ids = row.id || this.ids;
  300. this.$confirm('是否确认删除"' + row.certTitle + '"的数据项?', "警告", {
  301. confirmButtonText: "确定",
  302. cancelButtonText: "取消",
  303. type: "warning"
  304. }).then(function() {
  305. return delCertificate(ids);
  306. }).then(() => {
  307. this.getList();
  308. this.msgSuccess("删除成功");
  309. }).catch(() => {});
  310. },
  311. /** 导出按钮操作 */
  312. handleExport() {
  313. this.download('exam/certificate/export', {
  314. ...this.queryParams
  315. }, `exam_certificate.xlsx`)
  316. }
  317. }
  318. };
  319. </script>
  320. <style scoped lang="scss">
  321. .certificate {
  322. display: flex!important;
  323. flex-direction: column;
  324. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  325. padding:20px!important;
  326. .button-box{
  327. width:190px;
  328. display: flex;
  329. }
  330. .form-box{
  331. }
  332. }
  333. </style>
  334. <style lang="scss">
  335. .cartifcate-dialog{
  336. .el-input-number__increase, .el-input-number__decrease{
  337. height:38px;
  338. }
  339. }
  340. </style>