猫妈狗爸伴宠师小程序后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
9.4 KiB

3 months ago
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px" size="medium" class="ry_form">
  4. <el-form-item label="考试题目" prop="examinationQuestions">
  5. <el-input
  6. v-model="queryParams.examinationQuestions"
  7. placeholder="请输入考试题目"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="问题类型,1为单选,2为多选,3为简答" prop="examinationTypeId">
  14. <el-input
  15. v-model="queryParams.examinationTypeId"
  16. placeholder="请输入问题类型,1为单选,2为多选,3为简答"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="备注" prop="reamk">
  23. <el-input
  24. v-model="queryParams.reamk"
  25. placeholder="请输入备注"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item class="flex_one tr">
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['model:examination:add']"
  45. >新增</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="success"
  50. plain
  51. icon="el-icon-edit"
  52. size="mini"
  53. :disabled="single"
  54. @click="handleUpdate"
  55. v-hasPermi="['model:examination:edit']"
  56. >修改</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="danger"
  61. plain
  62. icon="el-icon-delete"
  63. size="mini"
  64. :disabled="multiple"
  65. @click="handleDelete"
  66. v-hasPermi="['model:examination:remove']"
  67. >删除</el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="warning"
  72. plain
  73. icon="el-icon-download"
  74. size="mini"
  75. :loading="exportLoading"
  76. @click="handleExport"
  77. v-hasPermi="['model:examination:export']"
  78. >导出</el-button>
  79. </el-col>
  80. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
  81. </el-row>
  82. <el-table v-loading="loading" :data="examinationList" @selection-change="handleSelectionChange">
  83. <el-table-column type="selection" width="55" align="center" />
  84. <el-table-column label="考试编号" align="center" prop="examinationId" />
  85. <el-table-column label="考试题目" align="center" prop="examinationQuestions" v-if="columns[0].visible"/>
  86. <el-table-column label="问题类型,1为单选,2为多选,3为简答" align="center" prop="examinationTypeId" v-if="columns[1].visible"/>
  87. <el-table-column label="备注" align="center" prop="reamk" v-if="columns[2].visible"/>
  88. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  89. <template slot-scope="scope">
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-edit"
  94. @click="handleUpdate(scope.row)"
  95. v-hasPermi="['model:examination:edit']"
  96. >修改</el-button>
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-delete"
  101. @click="handleDelete(scope.row)"
  102. v-hasPermi="['model:examination:remove']"
  103. >删除</el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <pagination
  108. v-show="total>0"
  109. :total="total"
  110. :page.sync="queryParams.pageNum"
  111. :limit.sync="queryParams.pageSize"
  112. @pagination="getList"
  113. />
  114. <!-- 添加或修改考核对话框 -->
  115. <el-dialog :title="title" :visible.sync="open" width="50%" append-to-body>
  116. <el-form ref="form" :model="form" :rules="rules" label-width="108px" inline class="dialog-form-two">
  117. <el-form-item label="删除标识" prop="delFlag">
  118. <el-input v-model="form.delFlag" placeholder="请输入删除标识" />
  119. </el-form-item>
  120. <el-form-item label="考试题目" prop="examinationQuestions">
  121. <el-input v-model="form.examinationQuestions" placeholder="请输入考试题目" />
  122. </el-form-item>
  123. <el-form-item label="问题类型,1为单选,2为多选,3为简答" prop="examinationTypeId">
  124. <el-input v-model="form.examinationTypeId" placeholder="请输入问题类型,1为单选,2为多选,3为简答" />
  125. </el-form-item>
  126. <el-form-item label="备注" prop="reamk">
  127. <el-input v-model="form.reamk" placeholder="请输入备注" />
  128. </el-form-item>
  129. </el-form>
  130. <div slot="footer" class="dialog-footer">
  131. <el-button type="primary" @click="submitForm"> </el-button>
  132. <el-button @click="cancel"> </el-button>
  133. </div>
  134. </el-dialog>
  135. </div>
  136. </template>
  137. <script>
  138. import { listExamination, getExamination, delExamination, addExamination, updateExamination, exportExamination } from "@/api/model/examination";
  139. export default {
  140. name: "Examination",
  141. data() {
  142. return {
  143. // 遮罩层
  144. loading: true,
  145. // 导出遮罩层
  146. exportLoading: false,
  147. // 选中数组
  148. ids: [],
  149. // 非单个禁用
  150. single: true,
  151. // 非多个禁用
  152. multiple: true,
  153. // 显示搜索条件
  154. showSearch: true,
  155. // 总条数
  156. total: 0,
  157. // 考核表格数据
  158. examinationList: [],
  159. // 弹出层标题
  160. title: "",
  161. // 是否显示弹出层
  162. open: false,
  163. // 查询参数
  164. queryParams: {
  165. pageNum: 1,
  166. pageSize: 10,
  167. examinationQuestions: null,
  168. examinationTypeId: null,
  169. reamk: null,
  170. },
  171. // 表单参数
  172. form: {},
  173. // 表单校验
  174. rules: {
  175. },
  176. columns: [
  177. { key: 4, label: "考试题目", visible: true },
  178. { key: 5, label: "问题类型,1为单选,2为多选,3为简答", visible: true },
  179. { key: 6, label: "备注", visible: true },
  180. ],
  181. };
  182. },
  183. created() {
  184. this.getList();
  185. },
  186. methods: {
  187. /** 查询考核列表 */
  188. getList() {
  189. this.loading = true;
  190. listExamination(this.queryParams).then(response => {
  191. this.examinationList = response.rows;
  192. this.total = response.total;
  193. this.loading = false;
  194. });
  195. },
  196. // 取消按钮
  197. cancel() {
  198. this.open = false;
  199. this.reset();
  200. },
  201. // 表单重置
  202. reset() {
  203. this.form = {
  204. examinationId: null,
  205. createBy: null,
  206. createTime: null,
  207. delFlag: null,
  208. examinationQuestions: null,
  209. examinationTypeId: null,
  210. reamk: null,
  211. updateBy: null,
  212. updateTime: null,
  213. };
  214. this.resetForm("form");
  215. },
  216. /** 搜索按钮操作 */
  217. handleQuery() {
  218. this.queryParams.pageNum = 1;
  219. this.getList();
  220. },
  221. /** 重置按钮操作 */
  222. resetQuery() {
  223. this.resetForm("queryForm");
  224. this.handleQuery();
  225. },
  226. // 多选框选中数据
  227. handleSelectionChange(selection) {
  228. this.ids = selection.map(item => item.examinationId)
  229. this.single = selection.length!==1
  230. this.multiple = !selection.length
  231. },
  232. /** 新增按钮操作 */
  233. handleAdd() {
  234. this.reset();
  235. this.open = true;
  236. this.title = "添加考核";
  237. },
  238. /** 修改按钮操作 */
  239. handleUpdate(row) {
  240. this.reset();
  241. const examinationId = row.examinationId || this.ids
  242. getExamination(examinationId).then(response => {
  243. this.form = response.data;
  244. this.open = true;
  245. this.title = "修改考核";
  246. });
  247. },
  248. /** 提交按钮 */
  249. submitForm() {
  250. this.$refs["form"].validate(valid => {
  251. if (valid) {
  252. if (this.form.examinationId != null) {
  253. updateExamination(this.form).then(response => {
  254. this.$modal.msgSuccess("修改成功");
  255. this.open = false;
  256. this.getList();
  257. });
  258. } else {
  259. addExamination(this.form).then(response => {
  260. this.$modal.msgSuccess("新增成功");
  261. this.open = false;
  262. this.getList();
  263. });
  264. }
  265. }
  266. });
  267. },
  268. /** 删除按钮操作 */
  269. handleDelete(row) {
  270. const examinationIds = row.examinationId || this.ids;
  271. this.$modal.confirm('是否确认删除考核编号为"' + examinationIds + '"的数据项?').then(function() {
  272. return delExamination(examinationIds);
  273. }).then(() => {
  274. this.getList();
  275. this.$modal.msgSuccess("删除成功");
  276. }).catch(() => {});
  277. },
  278. /** 导出按钮操作 */
  279. handleExport() {
  280. const queryParams = this.queryParams;
  281. this.$modal.confirm('是否确认导出所有考核数据项?').then(() => {
  282. this.exportLoading = true;
  283. return exportExamination(queryParams);
  284. }).then(response => {
  285. this.download(response.msg);
  286. this.exportLoading = false;
  287. }).catch(() => {});
  288. }
  289. }
  290. };
  291. </script>