index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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="topic">
  5. <el-input
  6. v-model="queryParams.topic"
  7. placeholder="请输入培训主题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['bccnew:ysPlan:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. icon="el-icon-edit"
  32. size="mini"
  33. :disabled="single"
  34. @click="handleUpdate"
  35. v-hasPermi="['bccnew:ysPlan:edit']"
  36. >修改</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['bccnew:ysPlan:remove']"
  46. >删除</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="info"
  51. icon="el-icon-upload2"
  52. size="mini"
  53. @click="handleImport"
  54. v-hasPermi="['bccnew:ysPlan:edit']"
  55. >导入</el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="warning"
  60. icon="el-icon-download"
  61. size="mini"
  62. @click="handleExport"
  63. v-hasPermi="['bccnew:ysPlan:export']"
  64. >导出</el-button>
  65. </el-col>
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <el-table v-loading="loading" :data="ysPlanList" @selection-change="handleSelectionChange" :height="clientHeight" :span-method="mergeMethod" border>
  69. <el-table-column type="selection" width="55" align="center"/>
  70. <el-table-column label="详细计划" align="center" prop="detailPlan"
  71. fixed="left"/>
  72. <el-table-column label="培训主题" align="center" prop="topic" fixed="left"
  73. />
  74. <el-table-column label="培训计划" align="center" prop="courseDay" />
  75. <el-table-column label="培训内容" align="center" prop="content" />
  76. <el-table-column label="应学习时长(分)" align="center" prop="timerNeed"/>
  77. <el-table-column label="备注" align="center" prop="remarks"/>
  78. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  79. <template slot-scope="scope">
  80. <el-button
  81. size="mini"
  82. type="text"
  83. icon="el-icon-edit"
  84. @click="handleUpdate(scope.row)"
  85. v-hasPermi="['bccnew:ysPlan:edit']"
  86. >修改</el-button>
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-delete"
  91. @click="handleDelete(scope.row)"
  92. v-hasPermi="['bccnew:ysPlan:remove']"
  93. >删除</el-button>
  94. <el-button
  95. size="mini"
  96. type="text"
  97. icon="el-icon-folder"
  98. @click="uploadFile(scope.row)"
  99. v-hasPermi="['bccnew:ysPlan:edit']"
  100. >学习资料
  101. </el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <pagination
  106. v-show="total>0"
  107. :total="total"
  108. :page.sync="queryParams.pageNum"
  109. :limit.sync="queryParams.pageSize"
  110. @pagination="getList"
  111. />
  112. <!-- 添加或修改压缩培训模版对话框 -->
  113. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  114. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  115. <el-form-item label="详细计划" prop="detailPlan">
  116. <el-input v-model="form.detailPlan" placeholder="请输入详细计划"/>
  117. </el-form-item>
  118. <el-form-item label="培训主题" prop="topic">
  119. <el-input v-model="form.topic" placeholder="请输入培训主题"/>
  120. </el-form-item>
  121. <el-form-item label="培训排序" prop="sortTmpl">
  122. <el-input-number v-model="form.sortTmpl" placeholder="请输入培训排序" style="width:100%;"/>
  123. </el-form-item>
  124. <el-form-item label="应学习时长(分)" prop="timerNeed">
  125. <el-input-number v-model="form.timerNeed" placeholder="请输入应学习时长" style="width: 100%"/>
  126. </el-form-item>
  127. <el-form-item label="备注" prop="remarks">
  128. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  129. </el-form-item>
  130. </el-form>
  131. <div slot="footer" class="dialog-footer">
  132. <el-button type="primary" @click="submitForm">确 定</el-button>
  133. <el-button @click="cancel">取 消</el-button>
  134. </div>
  135. </el-dialog>
  136. <!-- 用户导入对话框 -->
  137. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  138. <el-upload
  139. ref="upload"
  140. :limit="1"
  141. accept=".xlsx, .xls"
  142. :headers="upload.headers"
  143. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  144. :disabled="upload.isUploading"
  145. :on-progress="handleFileUploadProgress"
  146. :on-success="handleFileSuccess"
  147. :auto-upload="false"
  148. drag
  149. >
  150. <i class="el-icon-upload"></i>
  151. <div class="el-upload__text">
  152. {{ $t('将文件拖到此处,或') }}
  153. <em>{{ $t('点击上传') }}</em>
  154. </div>
  155. <div class="el-upload__tip" slot="tip">
  156. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  157. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  158. </div>
  159. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  160. <input name="type" :value="upload.type" hidden />
  161. </form>
  162. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  163. </el-upload>
  164. <div slot="footer" class="dialog-footer">
  165. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  166. <el-button @click="upload.open = false">取 消</el-button>
  167. </div>
  168. </el-dialog>
  169. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="1000px"
  170. append-to-body>
  171. <el-upload
  172. ref="doc"
  173. :limit="50"
  174. :headers="doc.headers"
  175. :action="doc.url+'/'+doc.id"
  176. :disabled="doc.isUploading"
  177. :on-progress="handleFileDocProgress"
  178. :on-success="handleFileDocSuccess"
  179. :file-list="doc.file"
  180. :auto-upload="true"
  181. drag
  182. >
  183. <i class="el-icon-upload"></i>
  184. <div class="el-upload__text">
  185. {{ $t('将文件拖到此处,或') }}
  186. <em>{{ $t('点击上传') }}</em>
  187. </div>
  188. </el-upload>
  189. <el-table :data="doc.commonfileList" border>
  190. <el-table-column :label="$t('文件名')" align="center" prop="fileName">
  191. <template slot-scope="scope">
  192. <a class="link-type" @click="handleDownload(scope.row)">
  193. <span>{{ scope.row.fileName }}</span>
  194. </a>
  195. </template>
  196. </el-table-column>
  197. <!-- <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize"-->
  198. <!-- width="80"/>-->
  199. <!-- <el-table-column :label="$t('上传人')" align="center" prop="creator" width="120"/>-->
  200. <el-table-column :label="$t('操作')" align="center" width="220" class-name="small-padding fixed-width">
  201. <template slot-scope="scope">
  202. <el-button
  203. v-if="scope.row.fileName!=null&&scope.row.fileName.endsWith('pdf')"
  204. size="mini"
  205. type="text"
  206. icon="el-icon-view"
  207. @click="handleSee(scope.row)"
  208. >{{ $t('预览') }}
  209. </el-button>
  210. <el-button v-hasPermi="['training:trainingrecords:file']" type="text" size="small" v-if="scope.row.isEdit"
  211. @click="save(scope.row)">保存
  212. </el-button>
  213. <el-button type="text" size="small" v-if="scope.row.isEdit" @click="cancelFile(scope.row, scope.$index)">
  214. 取消
  215. </el-button>
  216. <el-button
  217. size="mini"
  218. type="text"
  219. icon="el-icon-download"
  220. @click="handleDownload(scope.row)"
  221. >{{ $t('下载') }}
  222. </el-button>
  223. <el-button
  224. size="mini"
  225. type="text"
  226. icon="el-icon-delete"
  227. @click="handleDeleteDoc(scope.row)"
  228. v-hasPermi="['training:trainingrecords:file']"
  229. >{{ $t('删除') }}
  230. </el-button>
  231. </template>
  232. </el-table-column>
  233. </el-table>
  234. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px"
  235. append-to-body>
  236. <div style="margin-top: -60px;float: right;margin-right: 40px;">
  237. <el-button size="mini" type="text" @click="openPdf">{{ $t('新页面打开PDF') }}</el-button>
  238. </div>
  239. <div style="margin-top: -30px">
  240. <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
  241. </div>
  242. </el-dialog>
  243. <div slot="footer" class="dialog-footer">
  244. <!-- <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
  245. <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
  246. </div>
  247. </el-dialog>
  248. </div>
  249. </template>
  250. <script>
  251. import { listYsPlan, getYsPlan, delYsPlan, addYsPlan, updateYsPlan, exportYsPlan, importTemplate} from "@/api/training/bccnew/ysPlan";
  252. import { treeselect } from "@/api/system/dept";
  253. import { getToken } from "@/utils/auth";
  254. import Treeselect from "@riophae/vue-treeselect";
  255. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  256. import Editor from '@/components/Editor/index.vue';
  257. import {getFirstPlanTmpl, updateFirstPlanTmpl} from "@/api/training/bccnew/firstPlanTmpl";
  258. export default {
  259. name: "YsPlan",
  260. components: { Treeselect },
  261. // components: { Editor },
  262. data() {
  263. return {
  264. // 报告附件参数
  265. doc: {
  266. file: null,
  267. // 是否显示弹出层(报告附件)
  268. open: false,
  269. // 弹出层标题(报告附件)
  270. title: "附件",
  271. // 是否禁用上传
  272. isUploading: false,
  273. // 是否更新已经存在的用户数据
  274. updateSupport: 0,
  275. // 报告附件上传位置编号
  276. ids: 0,
  277. id: null,
  278. // 设置上传的请求头部
  279. headers: {Authorization: "Bearer " + getToken()},
  280. // 上传的地址
  281. url: process.env.VUE_APP_BASE_API + "/bccnew/ysPlanTmpl/uploadFile",
  282. commonfileList: null,
  283. queryParams: {
  284. pId: null,
  285. pType: 'bccnew'
  286. },
  287. pType: 'bccnew',
  288. pId: null,
  289. form: {}
  290. },
  291. pdf: {
  292. title: '',
  293. pdfUrl: '',
  294. numPages: null,
  295. open: false,
  296. pageNum: 1,
  297. pageTotalNum: 1,
  298. loadedRatio: 0,
  299. },
  300. // 遮罩层
  301. loading: true,
  302. // 选中数组
  303. ids: [],
  304. // 非单个禁用
  305. single: true,
  306. // 非多个禁用
  307. multiple: true,
  308. // 显示搜索条件
  309. showSearch: false,
  310. // 总条数
  311. total: 0,
  312. // 压缩培训模版表格数据
  313. ysPlanList: [],
  314. // 弹出层标题
  315. title: "",
  316. // 部门树选项
  317. deptOptions: undefined,
  318. clientHeight:300,
  319. // 是否显示弹出层
  320. open: false,
  321. // 用户导入参数
  322. upload: {
  323. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  324. //下载模板类型
  325. type: "ysPlanTmpl",
  326. // 是否显示弹出层(用户导入)
  327. open: false,
  328. // 弹出层标题(用户导入)
  329. title: "",
  330. // 是否禁用上传
  331. isUploading: false,
  332. // 是否更新已经存在的用户数据
  333. updateSupport: 0,
  334. // 设置上传的请求头部
  335. headers: { Authorization: "Bearer " + getToken() },
  336. // 上传的地址
  337. url: process.env.VUE_APP_BASE_API + "/bccnew/ysPlan/importData"
  338. },
  339. // 查询参数
  340. queryParams: {
  341. pageNum: 1,
  342. pageSize: 20,
  343. newId: null,
  344. courseCode: null,
  345. topic: null,
  346. content: null,
  347. courseDay: null,
  348. courseHour: null,
  349. detailPlan: null,
  350. trainer: null,
  351. courseDate: null,
  352. assess: null,
  353. createrCode: null,
  354. createdate: null,
  355. updaterCode: null,
  356. updatedate: null,
  357. deptId: null,
  358. remarks: null
  359. },
  360. // 表单参数
  361. form: {},
  362. // 表单校验
  363. rules: {
  364. }
  365. };
  366. },
  367. watch: {
  368. // 根据名称筛选部门树
  369. deptName(val) {
  370. this.$refs.tree.filter(val);
  371. }
  372. },
  373. created() {
  374. //设置表格高度对应屏幕高度
  375. this.$nextTick(() => {
  376. this.clientHeight = document.body.clientHeight -250
  377. })
  378. this.getList();
  379. this.getTreeselect();
  380. },
  381. methods: {
  382. uploadFile(row) {
  383. this.doc.file = null;
  384. this.doc.commonfileList = [];
  385. this.doc.open = true;
  386. this.doc.id = row.id;
  387. getFirstPlanTmpl(row.id).then(res => {
  388. if (res.data.fileUrl != null)
  389. this.doc.commonfileList.push({fileUrl: res.data.fileUrl, fileName: res.data.fileName, id: res.data.id})
  390. })
  391. this.$nextTick(()=>{
  392. this.$refs.doc.clearFiles();
  393. })
  394. },
  395. // 文件下载处理
  396. handleDownload(row) {
  397. var name = row.fileName;
  398. var url = row.fileUrl;
  399. var suffix = url.substring(url.lastIndexOf("."), url.length);
  400. const a = document.createElement('a')
  401. a.setAttribute('download', name)
  402. a.setAttribute('target', '_blank')
  403. a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
  404. a.click()
  405. },
  406. openPdf() {
  407. window.open(this.pdf.pdfUrl);//path是文件的全路径地址
  408. },
  409. handleSee(row) {
  410. // window.open(process.env.VUE_APP_BASE_API +'/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl);//path是文件的全路径地址
  411. this.pdf.open = true
  412. this.pdf.title = row.fileName
  413. this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
  414. },
  415. /** 删除按钮操作 */
  416. handleDeleteDoc(row) {
  417. const ids = row.id || this.ids;
  418. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  419. confirmButtonText: this.$t('确定'),
  420. cancelButtonText: this.$t('取消'),
  421. type: "warning"
  422. }).then(function () {
  423. return updateFirstPlanTmpl({id: row.id, fileUrl: '', fileName: ''});
  424. }).then(() => {
  425. this.msgSuccess(this.$t('删除成功'));
  426. this.doc.commonfileList = [];
  427. })
  428. },
  429. // 上传中处理
  430. handleFileDocProgress(event, file, fileList) {
  431. this.doc.file = file;
  432. this.doc.isUploading = true;
  433. },
  434. //附件上传成功处理
  435. handleFileDocSuccess(response, file, fileList) {
  436. this.doc.isUploading = false;
  437. this.$alert(response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
  438. this.getList();
  439. this.doc.commonfileList = [];
  440. getFirstPlanTmpl(response.data).then(res => {
  441. if (res.data.fileUrl != null) {
  442. this.doc.commonfileList.push({fileUrl: res.data.fileUrl, fileName: res.data.fileName, id: res.data.id})
  443. }
  444. })
  445. },
  446. /** 查询压缩培训模版列表 */
  447. getList() {
  448. this.loading = true;
  449. listYsPlan(this.queryParams).then(response => {
  450. this.ysPlanList = response.data;
  451. this.total = 0;
  452. this.loading = false;
  453. });
  454. },
  455. /** 查询部门下拉树结构 */
  456. getTreeselect() {
  457. treeselect().then(response => {
  458. this.deptOptions = response.data;
  459. });
  460. },
  461. // 取消按钮
  462. cancel() {
  463. this.open = false;
  464. this.reset();
  465. },
  466. // 表单重置
  467. reset() {
  468. this.form = {
  469. id: null,
  470. newId: null,
  471. courseCode: null,
  472. topic: null,
  473. content: null,
  474. courseDay: null,
  475. courseHour: null,
  476. detailPlan: null,
  477. trainer: null,
  478. courseDate: null,
  479. assess: null,
  480. delFlag: null,
  481. createrCode: null,
  482. createdate: null,
  483. updaterCode: null,
  484. updatedate: null,
  485. deptId: null,
  486. remarks: null
  487. };
  488. this.resetForm("form");
  489. },
  490. /** 搜索按钮操作 */
  491. handleQuery() {
  492. this.queryParams.pageNum = 1;
  493. this.getList();
  494. },
  495. /** 重置按钮操作 */
  496. resetQuery() {
  497. this.resetForm("queryForm");
  498. this.handleQuery();
  499. },
  500. // 多选框选中数据
  501. handleSelectionChange(selection) {
  502. this.ids = selection.map(item => item.id)
  503. this.single = selection.length!==1
  504. this.multiple = !selection.length
  505. },
  506. /** 新增按钮操作 */
  507. handleAdd() {
  508. this.reset();
  509. this.open = true;
  510. this.title = "添加压缩培训模版";
  511. },
  512. /** 修改按钮操作 */
  513. handleUpdate(row) {
  514. this.reset();
  515. const id = row.id || this.ids
  516. getYsPlan(id).then(response => {
  517. this.form = response.data;
  518. this.open = true;
  519. this.title = "修改压缩培训模版";
  520. });
  521. },
  522. /** 提交按钮 */
  523. submitForm() {
  524. this.$refs["form"].validate(valid => {
  525. if (valid) {
  526. if (this.form.id != null) {
  527. updateYsPlan(this.form).then(response => {
  528. this.msgSuccess("修改成功");
  529. this.open = false;
  530. this.getList();
  531. });
  532. } else {
  533. addYsPlan(this.form).then(response => {
  534. this.msgSuccess("新增成功");
  535. this.open = false;
  536. this.getList();
  537. });
  538. }
  539. }
  540. });
  541. },
  542. /** 删除按钮操作 */
  543. handleDelete(row) {
  544. const ids = row.id || this.ids;
  545. this.$confirm('是否确认删除?', "警告", {
  546. confirmButtonText: "确定",
  547. cancelButtonText: "取消",
  548. type: "warning"
  549. }).then(function() {
  550. return delYsPlan(ids);
  551. }).then(() => {
  552. this.getList();
  553. this.msgSuccess("删除成功");
  554. })
  555. },
  556. /** 导出按钮操作 */
  557. handleExport() {
  558. const queryParams = this.queryParams;
  559. this.$confirm('是否确认导出所有压缩培训模版数据项?', "警告", {
  560. confirmButtonText: "确定",
  561. cancelButtonText: "取消",
  562. type: "warning"
  563. }).then(function() {
  564. return exportYsPlan(queryParams);
  565. }).then(response => {
  566. this.download(response.msg);
  567. })
  568. },
  569. /** 导入按钮操作 */
  570. handleImport() {
  571. this.upload.title = "用户导入";
  572. this.upload.open = true;
  573. },
  574. /** 下载模板操作 */
  575. importTemplate() {
  576. this.$refs['downloadFileForm'].submit()
  577. },
  578. // 文件上传中处理
  579. handleFileUploadProgress(event, file, fileList) {
  580. this.upload.isUploading = true;
  581. },
  582. // 文件上传成功处理
  583. handleFileSuccess(response, file, fileList) {
  584. this.upload.open = false;
  585. this.upload.isUploading = false;
  586. this.$refs.upload.clearFiles();
  587. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  588. this.getList();
  589. },
  590. //合并单元格
  591. mergeMethod({row, column, rowIndex, columnIndex}) {
  592. // console.log(row)
  593. if ([1,2,5,6,7].includes(columnIndex)) {
  594. const _row = this.setTable(this.ysPlanList).merge[rowIndex];
  595. const _col = _row > 0 ? 1 : 0;
  596. return {
  597. rowspan: _row,
  598. colspan: _col
  599. };
  600. }
  601. },
  602. //单元格整理
  603. setTable(tableData) {
  604. // console.log(tableData)
  605. let spanArr = [],
  606. concat = 0;
  607. tableData.forEach((item, index) => {
  608. if (index === 0) {
  609. spanArr.push(1);
  610. } else {
  611. if (item.topic === tableData[index - 1].topic) {
  612. //第一列需合并相同内容的判断条件
  613. spanArr[concat] += 1;
  614. spanArr.push(0);
  615. } else {
  616. spanArr.push(1);
  617. concat = index;
  618. }
  619. }
  620. });
  621. return {
  622. merge: spanArr
  623. };
  624. },
  625. // 提交上传文件
  626. submitFileForm() {
  627. this.$refs.upload.submit();
  628. }
  629. }
  630. };
  631. </script>