index.vue 17 KB

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