index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="课程编号" prop="courseCode">
  5. <el-input
  6. v-model="queryParams.courseCode"
  7. placeholder="请输入课程编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="培训主题" prop="topic">
  14. <el-input
  15. v-model="queryParams.topic"
  16. placeholder="请输入培训主题"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="详细计划" prop="detailPlan">
  23. <el-input
  24. v-model="queryParams.detailPlan"
  25. placeholder="请输入详细计划"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="培训日期" prop="courseDate">
  32. <el-date-picker clearable size="small" style="width: 200px"
  33. v-model="queryParams.courseDate"
  34. type="date"
  35. value-format="yyyy-MM-dd"
  36. placeholder="选择培训日期">
  37. </el-date-picker>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  41. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  42. </el-form-item>
  43. </el-form>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button
  47. type="primary"
  48. icon="el-icon-plus"
  49. size="mini"
  50. @click="handleAdd"
  51. v-hasPermi="['newstaff:schoolplan:add']"
  52. >新增</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="success"
  57. icon="el-icon-edit"
  58. size="mini"
  59. :disabled="single"
  60. @click="handleUpdate"
  61. v-hasPermi="['newstaff:schoolplan:edit']"
  62. >修改</el-button>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-button
  66. type="danger"
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['newstaff:schoolplan:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="primary"
  77. icon="el-icon-edit"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleBatchPlan"
  81. v-hasPermi="['newstaff:schoolplan:edit']"
  82. >批量完成</el-button>
  83. </el-col>
  84. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  85. </el-row>
  86. <el-table v-loading="loading" :data="schoolplanList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  87. <el-table-column type="selection" width="55" align="center" />
  88. <el-table-column label="课程编号" align="center" prop="courseCode" :show-overflow-tooltip="true"/>
  89. <el-table-column label="培训主题" align="center" prop="topic" :show-overflow-tooltip="true"/>
  90. <el-table-column label="培训内容" align="center" prop="content" :show-overflow-tooltip="true"/>
  91. <el-table-column label="培训天" align="center" prop="courseDay" :show-overflow-tooltip="true"/>
  92. <el-table-column label="培训小时" align="center" prop="courseHour" :show-overflow-tooltip="true"/>
  93. <el-table-column label="详细计划" align="center" prop="detailPlan" :show-overflow-tooltip="true"/>
  94. <el-table-column label="培训日期" align="center" prop="courseDate" width="100">
  95. <template slot-scope="scope">
  96. <span>{{ parseTime(scope.row.courseDate, '{y}-{m}-{d}') }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="考核情况" align="center" prop="assess" :show-overflow-tooltip="true"/>
  100. <el-table-column label="培训状态" align="center" prop="planStatus" :formatter="planStatusFormat" >
  101. <template slot-scope="scope">
  102. <el-tag v-if="scope.row.planStatus == 1" size="small" type="success">已完成</el-tag>
  103. <el-tag v-else-if="scope.row.planStatus == 0" size="small" type="info">未完成</el-tag>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  107. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  108. <template slot-scope="scope">
  109. <el-button
  110. size="mini"
  111. type="text"
  112. icon="el-icon-edit"
  113. @click="handleUpdate(scope.row)"
  114. v-hasPermi="['newstaff:schoolplan:edit']"
  115. >修改</el-button>
  116. <el-button
  117. size="mini"
  118. type="text"
  119. icon="el-icon-delete"
  120. @click="handleDelete(scope.row)"
  121. v-hasPermi="['newstaff:schoolplan:remove']"
  122. >删除</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <pagination
  127. v-show="total>0"
  128. :total="total"
  129. :page.sync="queryParams.pageNum"
  130. :limit.sync="queryParams.pageSize"
  131. @pagination="getList"
  132. />
  133. <!-- 添加或修改校招培训对话框 -->
  134. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  135. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  136. <el-form-item label="课程编号" prop="courseCode">
  137. <el-input v-model="form.courseCode" placeholder="请输入课程编号" />
  138. </el-form-item>
  139. <el-form-item label="培训主题" prop="topic">
  140. <el-input v-model="form.topic" placeholder="请输入培训主题" />
  141. </el-form-item>
  142. <el-form-item label="培训内容" prop="content">
  143. <el-input v-model="form.content" type="textarea" placeholder="请输入内容" />
  144. </el-form-item>
  145. <el-form-item label="培训天" prop="courseDay">
  146. <el-input v-model="form.courseDay" placeholder="请输入培训天" />
  147. </el-form-item>
  148. <el-form-item label="培训小时" prop="courseHour">
  149. <el-input v-model="form.courseHour" placeholder="请输入培训小时" />
  150. </el-form-item>
  151. <el-form-item label="详细计划" prop="detailPlan">
  152. <el-input v-model="form.detailPlan" placeholder="请输入详细计划" />
  153. </el-form-item>
  154. <el-form-item label="培训日期" prop="courseDate">
  155. <el-date-picker clearable size="small" style="width: 200px"
  156. v-model="form.courseDate"
  157. type="date"
  158. value-format="yyyy-MM-dd"
  159. placeholder="选择培训日期">
  160. </el-date-picker>
  161. </el-form-item>
  162. <el-form-item label="考核情况" prop="assess">
  163. <el-input v-model="form.assess" placeholder="请输入考核情况" />
  164. </el-form-item>
  165. <el-form-item label="培训状态">
  166. <el-select v-model="form.planStatus" placeholder="请选择培训状态">
  167. <el-option
  168. v-for="dict in planStatusOptions"
  169. :key="dict.dictValue"
  170. :label="dict.dictLabel"
  171. :value="parseInt(dict.dictValue)"
  172. ></el-option>
  173. </el-select>
  174. </el-form-item>
  175. <el-form-item label="备注" prop="remarks">
  176. <el-input v-model="form.remarks" placeholder="请输入备注" />
  177. </el-form-item>
  178. <el-form-item label="归属部门" prop="deptId">
  179. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  180. </el-form-item>
  181. </el-form>
  182. <div slot="footer" class="dialog-footer">
  183. <el-button type="primary" @click="submitForm">确 定</el-button>
  184. <el-button @click="cancel">取 消</el-button>
  185. </div>
  186. </el-dialog>
  187. <!-- 用户导入对话框 -->
  188. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  189. <el-upload
  190. ref="upload"
  191. :limit="1"
  192. accept=".xlsx, .xls"
  193. :headers="upload.headers"
  194. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  195. :disabled="upload.isUploading"
  196. :on-progress="handleFileUploadProgress"
  197. :on-success="handleFileSuccess"
  198. :auto-upload="false"
  199. drag
  200. >
  201. <i class="el-icon-upload"></i>
  202. <div class="el-upload__text">
  203. 将文件拖到此处,或
  204. <em>点击上传</em>
  205. </div>
  206. <div class="el-upload__tip" slot="tip">
  207. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  208. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  209. </div>
  210. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  211. </el-upload>
  212. <div slot="footer" class="dialog-footer">
  213. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  214. <el-button @click="upload.open = false">取 消</el-button>
  215. </div>
  216. </el-dialog>
  217. </div>
  218. </template>
  219. <script>
  220. import { listSchoolplan,batchStatus, getSchoolplan, delSchoolplan, addSchoolplan, updateSchoolplan, exportSchoolplan, importTemplate} from "@/api/training/newstaff/schoolplan";
  221. import { treeselect } from "@/api/system/dept";
  222. import { getToken } from "@/utils/auth";
  223. import Treeselect from "@riophae/vue-treeselect";
  224. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  225. export default {
  226. name: "Schoolplan",
  227. components: { Treeselect },
  228. data() {
  229. return {
  230. // 遮罩层
  231. loading: true,
  232. // 选中数组
  233. ids: [],
  234. // 非单个禁用
  235. single: true,
  236. // 非多个禁用
  237. multiple: true,
  238. // 显示搜索条件
  239. showSearch: false,
  240. // 总条数
  241. total: 0,
  242. // 校招培训表格数据
  243. schoolplanList: [],
  244. // 弹出层标题
  245. title: "",
  246. // 部门树选项
  247. deptOptions: undefined,
  248. clientHeight:300,
  249. // 培训状态字典
  250. planStatusOptions: [],
  251. // 是否显示弹出层
  252. open: false,
  253. // 用户导入参数
  254. upload: {
  255. // 是否显示弹出层(用户导入)
  256. open: false,
  257. // 弹出层标题(用户导入)
  258. title: "",
  259. // 是否禁用上传
  260. isUploading: false,
  261. // 是否更新已经存在的用户数据
  262. updateSupport: 0,
  263. // 设置上传的请求头部
  264. headers: { Authorization: "Bearer " + getToken() },
  265. // 上传的地址
  266. url: process.env.VUE_APP_BASE_API + "/newstaff/schoolplan/importData"
  267. },
  268. // 查询参数
  269. queryParams: {
  270. newId: null,
  271. pageNum: 1,
  272. pageSize: 20,
  273. courseCode: null,
  274. topic: null,
  275. detailPlan: null,
  276. trainer: null,
  277. courseDate: null,
  278. assess: null,
  279. },
  280. // 表单参数
  281. form: {},
  282. // 表单校验
  283. rules: {
  284. }
  285. };
  286. },
  287. watch: {
  288. // 根据名称筛选部门树
  289. deptName(val) {
  290. this.$refs.tree.filter(val);
  291. }
  292. },
  293. created() {
  294. //设置表格高度对应屏幕高度
  295. this.$nextTick(() => {
  296. this.clientHeight = document.body.clientHeight -250
  297. })
  298. this.queryParams.newId = this.$route.params && this.$route.params.newId;
  299. this.getDicts("training_newstaff_status").then(response => {
  300. this.planStatusOptions = response.data;
  301. });
  302. this.getList();
  303. this.getTreeselect();
  304. },
  305. methods: {
  306. /** 查询校招培训列表 */
  307. getList() {
  308. this.loading = true;
  309. listSchoolplan(this.queryParams).then(response => {
  310. this.schoolplanList = response.rows;
  311. this.total = response.total;
  312. this.loading = false;
  313. });
  314. },
  315. /** 查询部门下拉树结构 */
  316. getTreeselect() {
  317. treeselect().then(response => {
  318. this.deptOptions = response.data;
  319. });
  320. },
  321. // 取消按钮
  322. cancel() {
  323. this.open = false;
  324. this.reset();
  325. },
  326. // 表单重置
  327. reset() {
  328. this.form = {
  329. id: null,
  330. newId: null,
  331. courseCode: null,
  332. topic: null,
  333. content: null,
  334. courseDay: null,
  335. courseHour: null,
  336. detailPlan: null,
  337. trainer: null,
  338. courseDate: null,
  339. assess: null,
  340. delFlag: null,
  341. createrCode: null,
  342. createdate: null,
  343. updaterCode: null,
  344. updatedate: null,
  345. deptId: null,
  346. remarks: null
  347. };
  348. this.resetForm("form");
  349. },
  350. /** 搜索按钮操作 */
  351. handleQuery() {
  352. this.queryParams.pageNum = 1;
  353. this.getList();
  354. },
  355. /** 重置按钮操作 */
  356. resetQuery() {
  357. this.resetForm("queryForm");
  358. this.handleQuery();
  359. },
  360. // 多选框选中数据
  361. handleSelectionChange(selection) {
  362. this.ids = selection.map(item => item.id)
  363. this.single = selection.length!==1
  364. this.multiple = !selection.length
  365. },
  366. /** 新增按钮操作 */
  367. handleAdd() {
  368. this.reset();
  369. this.open = true;
  370. this.title = "添加校招培训";
  371. },
  372. /** 修改按钮操作 */
  373. handleUpdate(row) {
  374. this.reset();
  375. const id = row.id || this.ids
  376. getSchoolplan(id).then(response => {
  377. this.form = response.data;
  378. this.open = true;
  379. this.title = "修改校招培训";
  380. });
  381. },
  382. /** 提交按钮 */
  383. submitForm() {
  384. this.$refs["form"].validate(valid => {
  385. if (valid) {
  386. if (this.form.id != null) {
  387. updateSchoolplan(this.form).then(response => {
  388. this.msgSuccess("修改成功");
  389. this.open = false;
  390. this.getList();
  391. });
  392. } else {
  393. addSchoolplan(this.form).then(response => {
  394. this.msgSuccess("新增成功");
  395. this.open = false;
  396. this.getList();
  397. });
  398. }
  399. }
  400. });
  401. },
  402. /** 批量按钮操作 */
  403. handleBatchPlan(row) {
  404. const ids = row.id || this.ids;
  405. this.$confirm('是否确认批量完成?', "警告", {
  406. confirmButtonText: "确定",
  407. cancelButtonText: "取消",
  408. type: "warning"
  409. }).then(function() {
  410. return batchStatus(ids);
  411. }).then(() => {
  412. this.getList();
  413. this.msgSuccess("操作成功");
  414. })
  415. },
  416. /** 删除按钮操作 */
  417. handleDelete(row) {
  418. const ids = row.id || this.ids;
  419. this.$confirm('是否确认删除?', "警告", {
  420. confirmButtonText: "确定",
  421. cancelButtonText: "取消",
  422. type: "warning"
  423. }).then(function() {
  424. return delSchoolplan(ids);
  425. }).then(() => {
  426. this.getList();
  427. this.msgSuccess("删除成功");
  428. })
  429. },
  430. /** 导出按钮操作 */
  431. handleExport() {
  432. const queryParams = this.queryParams;
  433. this.$confirm('是否确认导出所有校招培训数据项?', "警告", {
  434. confirmButtonText: "确定",
  435. cancelButtonText: "取消",
  436. type: "warning"
  437. }).then(function() {
  438. return exportSchoolplan(queryParams);
  439. }).then(response => {
  440. this.download(response.msg);
  441. })
  442. },
  443. /** 导入按钮操作 */
  444. handleImport() {
  445. this.upload.title = "用户导入";
  446. this.upload.open = true;
  447. },
  448. /** 下载模板操作 */
  449. importTemplate() {
  450. importTemplate().then(response => {
  451. this.download(response.msg);
  452. });
  453. },
  454. // 文件上传中处理
  455. handleFileUploadProgress(event, file, fileList) {
  456. this.upload.isUploading = true;
  457. },
  458. // 文件上传成功处理
  459. handleFileSuccess(response, file, fileList) {
  460. this.upload.open = false;
  461. this.upload.isUploading = false;
  462. this.$refs.upload.clearFiles();
  463. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  464. this.getList();
  465. },
  466. // 提交上传文件
  467. submitFileForm() {
  468. this.$refs.upload.submit();
  469. }
  470. }
  471. };
  472. </script>