index.vue 16 KB

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