index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <!--检查项目库-->
  2. <template>
  3. <div class="app-container checkItemLibrary">
  4. <div class="title-box">
  5. <el-form class="form-box" :model="queryParams" ref="examineForm" :inline="true" label-width="80px">
  6. <el-form-item label="关键字" prop="name">
  7. <el-input
  8. maxlength="10"
  9. v-model="queryParams.searchValue"
  10. placeholder="序号/检查项目/检查要点"
  11. clearable
  12. size="small"/>
  13. </el-form-item>
  14. <el-form-item>
  15. <p class="inquire-button-one" @click="onSearch">查询</p>
  16. <p class="reset-button-one" @click="resetForm">重置</p>
  17. </el-form-item>
  18. <el-form-item style="float: right;" v-hasPermi="['check:option:add']">
  19. <p class="inquire-button-one" style="width:80px;" @click="addDialogOpen(1)">+ 添加</p>
  20. </el-form-item>
  21. <el-form-item style="float: right;" v-hasPermi="['check:option:remove']">
  22. <p class="add-button-two-90" style="width:100px;" @click="allDel">批量删除</p>
  23. </el-form-item>
  24. <el-form-item style="float: right;" v-hasPermi="['check:option:export']">
  25. <el-dropdown @command="exportButton">
  26. <div class="form-dropdown-box">
  27. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_sc.png">
  28. <p>导出</p>
  29. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  30. </div>
  31. <el-dropdown-menu slot="dropdown">
  32. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">导出全部数据</el-dropdown-item>
  33. <el-dropdown-item style="margin:0 10px;color:#333;" :command="{command:2}">导出选中数据</el-dropdown-item>
  34. </el-dropdown-menu>
  35. </el-dropdown>
  36. </el-form-item>
  37. <el-form-item style="float: right;">
  38. <el-dropdown @command="importButton">
  39. <div class="form-dropdown-box">
  40. <img src="@/assets/ZDimages/personnelManagement/icon_jzgxx_dr.png">
  41. <p>导入</p>
  42. <img src="@/assets/ZDimages/personnelManagement/icon_jzggl_xljt.png">
  43. </div>
  44. <el-dropdown-menu slot="dropdown">
  45. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;color:#333;" :command="{command:1}">下载模板</el-dropdown-item>
  46. <el-dropdown-item style="margin:0 10px;color:#333;" :command="{command:2}">导入数据</el-dropdown-item>
  47. </el-dropdown-menu>
  48. </el-dropdown>
  49. </el-form-item>
  50. </el-form>
  51. </div>
  52. <div class="content-box">
  53. <el-table border
  54. :data="tableData"
  55. ref="multipleTable" :row-key="getRowKeys"
  56. default-expand-all
  57. :select-on-indeterminate="false"
  58. @select="select"
  59. @select-all="selectAll"
  60. :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  61. <el-table-column type="selection" width="50" align="center"/>
  62. <el-table-column label="序号" prop="code" width="140"/>
  63. <el-table-column label="检查项目" prop="name"/>
  64. <el-table-column label="检查要点" prop="mainPoint" width="700"/>
  65. <el-table-column label="操作" width="180">
  66. <template slot-scope="scope">
  67. <div class="table-button-box">
  68. <p class="table-button-null"></p>
  69. <p class="table-button-p" v-if="scope.row.level != 3" v-hasPermi="['check:option:add']"
  70. @click="addDialogOpen(2,scope.row)">新增</p>
  71. <p class="table-button-p" @click="addDialogOpen(3,scope.row)" v-hasPermi="['check:option:edit']">编辑</p>
  72. <p class="table-button-p" @click="delItem(scope.row)" v-hasPermi="['check:option:remove']">删除</p>
  73. <p class="table-button-null"></p>
  74. </div>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. </div>
  79. <!--导入窗口-->
  80. <el-dialog title="导入数据" :visible.sync="importOpen" @close="importOpenOff" width="600px" append-to-body class="checkItemLibrary-dialog-box">
  81. <el-upload
  82. class="teacher-import-dialog-upLoad-box"
  83. :drag="true"
  84. :data="upImportData"
  85. :action="uploadImgUrl"
  86. :show-file-list="false"
  87. :on-success="handleAvatarSuccess"
  88. :headers="headers"
  89. :before-upload="beforeAvatarUpload">
  90. <i class="el-icon-upload"></i>
  91. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  92. <div class="el-upload__tip" slot="tip">
  93. <el-checkbox v-model="upImportData.upDate">更新替换已存在序号的数据</el-checkbox>
  94. </div>
  95. <div class="el-upload__tip" slot="tip">仅允许导入xls、xlsx、格式文件。<span style="color:#0183FA;cursor: pointer" v-hasPermi="['system:user_teacher:exceltemplate']" @click="importTemplate">下载模板</span></div>
  96. <div class="el-upload-text-box" slot="tip" v-if="getImportData.downFile">
  97. <div class="img-text-box">
  98. <img src="@/assets/ZDimages/personnelManagement/icon_dr_wj.png">
  99. <p>{{getImportData.textName}}</p>
  100. </div>
  101. <p class="text-p">数据导入成功 <span style="color:#0183FA;">{{getImportData.successNum}}</span> 条,失败 <span style="color:#FF6464 ;">{{getImportData.failureNum}}</span> 条</p>
  102. <div class="img-text-box">
  103. <img src="@/assets/ZDimages/personnelManagement/icon_dr_sj.png">
  104. <p style="color:#0183FA;cursor: pointer;" @click="failureExcel">点击下载失败数据报表</p>
  105. </div>
  106. </div>
  107. </el-upload>
  108. <div slot="footer" class="teacher-import-dialog-button-box">
  109. <p class="inquire-button-one" @click="importOpenOff">确定</p>
  110. </div>
  111. <div class="teacher-import-dialog-position-box" v-if="loading"></div>
  112. </el-dialog>
  113. <!--添加窗口-->
  114. <el-dialog :title="addDialogTitle" :visible.sync="addDialogType" v-if="addDialogType" @close="addDialogOff" width="780px" append-to-body class="checkItemLibrary-dialog-box">
  115. <el-form ref="addDialogForm" :model="addDialogForm" :rules="rules" label-width="120px">
  116. <el-form-item label="上级指标" prop="parentId">
  117. <el-cascader
  118. style="width:548px;"
  119. v-model="addDialogForm.parentId"
  120. :options="cascaderData"
  121. :props="{ checkStrictly: true, value: 'id', label: 'labelName',emitPath:false }"
  122. @change="cascaderCheck">
  123. <template slot-scope="{data}">
  124. <el-tooltip :content="data.labelName" v-if="data.labelName.length>22">
  125. <p style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  126. </el-tooltip>
  127. <p v-else style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  128. </template>
  129. </el-cascader>
  130. </el-form-item>
  131. <el-form-item label="添加序号" prop="code">
  132. <div class="code-max-box">
  133. <el-input v-model="addDialogForm.code" placeholder="未选择指标"
  134. maxLength="6" disabled style="width:500px;"/>
  135. <div class="code-button-box">
  136. <p class="el-icon-arrow-up" @click="codeButton(1)"></p>
  137. <p class="el-icon-arrow-down" @click="codeButton(2)"></p>
  138. </div>
  139. </div>
  140. </el-form-item>
  141. <el-form-item label="检查项目" prop="name">
  142. <el-input
  143. type="textarea"
  144. :autosize="{ minRows: 5, maxRows: 5}"
  145. placeholder="请输入检查项目内容"
  146. v-model="addDialogForm.name"
  147. maxlength="100"
  148. resize="none"
  149. show-word-limit
  150. style="width:548px;">
  151. </el-input>
  152. </el-form-item>
  153. <el-form-item label="检查要点" prop="mainPoint" v-if="addDialogLevel>1">
  154. <el-input
  155. type="textarea"
  156. :autosize="{ minRows: 8, maxRows: 8}"
  157. placeholder="请输入检查检查要点:"
  158. v-model="addDialogForm.mainPoint"
  159. maxlength="300"
  160. resize="none"
  161. show-word-limit
  162. style="width:548px;">
  163. </el-input>
  164. </el-form-item>
  165. </el-form>
  166. <div slot="footer" class="dialog-footer dialog-footer-box" style="display: flex">
  167. <p class="dialog-footer-button-null"></p>
  168. <p class="dialog-footer-button-info" @click="addDialogOff">取消</p>
  169. <p class="dialog-footer-button-primary" @click="upDataButton">确定</p>
  170. <p class="dialog-footer-button-null"></p>
  171. </div>
  172. </el-dialog>
  173. </div>
  174. </template>
  175. <script>
  176. import { checkOptionList,checkOptionAdd,checkOptionUpdate,checkOptionDelete,checkOptionBatchDelete } from '@/api/safetyCheck/index'
  177. import { getToken } from "@/utils/auth";
  178. export default {
  179. name: 'index',
  180. data(){
  181. return{
  182. uploadImgUrl: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/system/user/teacher/importData", // 上传地址
  183. headers: {
  184. Authorization: "Bearer " + getToken(),
  185. },
  186. // 遮罩层
  187. loading: false,
  188. queryParams:{
  189. searchValue:"",
  190. },
  191. //导入弹层开关
  192. importOpen:false,
  193. //导入数据
  194. upImportData:{
  195. sysUserEnable:true,
  196. upDate:false,
  197. },
  198. getImportData:{
  199. downFile:false,
  200. successNum:0,
  201. failureNum:0,
  202. textName:"",
  203. },
  204. // 检查项选项表格数据
  205. tableData: [],
  206. cascaderData:[],
  207. cascaderDataPrimitive:[],
  208. total:0,
  209. addDialogType:false,
  210. addDialogTitle:null,
  211. addDialogLevel:0,
  212. addDialogForm:{
  213. parentId:"",
  214. code:"",
  215. name:"",
  216. mainPoint:"",
  217. },
  218. // 表单校验
  219. rules: {
  220. parentId: [
  221. { required: true, message: "请选择上级指标", trigger: "change" },
  222. { required: true, message: "请选择上级指标", validator: this.spaceJudgment, trigger: "change" },
  223. ],
  224. name: [
  225. { required: true, message: "请输入检查项目内容", trigger: "change" },
  226. { required: true, message: "请输入检查项目内容", validator: this.spaceJudgment, trigger: "change" },
  227. ],
  228. },
  229. checkList:[],
  230. }
  231. },
  232. created(){
  233. },
  234. mounted(){
  235. this.getList();
  236. },
  237. methods:{
  238. //确定按钮
  239. upDataButton(){
  240. this.$refs["addDialogForm"].validate(valid => {
  241. if (valid) {
  242. if(this.addDialogForm.id){
  243. //编辑
  244. let obj = JSON.parse(JSON.stringify(this.addDialogForm))
  245. obj.level = this.addDialogLevel+1;
  246. obj.mainPoint = this.addDialogLevel>1?obj.mainPoint:'';
  247. checkOptionUpdate(obj).then( response => {
  248. this.msgSuccess(response.msg)
  249. this.addDialogOff();
  250. this.getList();
  251. })
  252. }else{
  253. //新增
  254. let obj = JSON.parse(JSON.stringify(this.addDialogForm))
  255. obj.level = this.addDialogLevel+1;
  256. checkOptionAdd(obj).then( response => {
  257. this.msgSuccess(response.msg)
  258. this.addDialogOff();
  259. this.getList();
  260. })
  261. }
  262. }
  263. })
  264. },
  265. //添加页面开启
  266. addDialogOpen(type,row){
  267. console.log('row',row)
  268. if(type == 1){
  269. //新增
  270. this.$set(this,'addDialogTitle','添加检查项目');
  271. this.$set(this,'addDialogLevel',0);
  272. this.$set(this,'addDialogForm',{
  273. parentId:"",
  274. code:"",
  275. name:"",
  276. mainPoint:"",
  277. });
  278. this.$set(this,'addDialogType',true);
  279. }else if(type == 2){
  280. //列表新增
  281. this.$set(this,'addDialogTitle','添加检查项目');
  282. let obj = this.cascaderCheckData(row.id,this.cascaderDataPrimitive);
  283. this.$set(this,'checkList',JSON.parse(JSON.stringify(row.children)));
  284. this.$set(this,'addDialogLevel',obj.level);
  285. this.$set(this,'addDialogForm',{
  286. parentId:row.id,
  287. code:obj.key,
  288. name:"",
  289. mainPoint:"",
  290. });
  291. this.$set(this,'addDialogType',true);
  292. }else if(type == 3){
  293. //编辑
  294. this.$set(this,'addDialogTitle','编辑检查项目');
  295. this.$set(this,'addDialogLevel',row.level-1);
  296. this.$set(this,'addDialogForm',{
  297. id:row.id,
  298. parentId:row.parentId,
  299. code:row.code,
  300. name:row.name,
  301. mainPoint:row.mainPoint,
  302. });
  303. this.getCodeButton(this.cascaderDataPrimitive,row.parentId,row.id);
  304. this.$set(this,'addDialogType',true);
  305. }
  306. },
  307. //添加页面关闭
  308. addDialogOff(){
  309. this.$set(this,'addDialogType',false);
  310. },
  311. //联级选中
  312. cascaderCheck(val){
  313. let obj = this.cascaderCheckData(val,this.cascaderDataPrimitive);
  314. this.$set(this.addDialogForm,'code',obj.key);
  315. this.getCodeButton(this.cascaderDataPrimitive,obj.parentId,val);
  316. this.$set(this,'addDialogLevel',obj.level);
  317. },
  318. //序号自增
  319. cascaderCheckData(val,list){
  320. let self = this;
  321. for(let i=0;i<list.length;i++){
  322. if(list[i].id == val){
  323. let obj = {
  324. parentId:list[i].id,
  325. parentKey:list[i].code,
  326. level:list[i].level,
  327. key:'',
  328. }
  329. if(list[i].children){
  330. if(list[i].children[0]){
  331. obj.key = list[i].code ? list[i].code + '.' + self.getListKey(list[i].children) : self.getListKey(list[i].children)
  332. }else{
  333. obj.key = list[i].code ? list[i].code+'.1':'1'
  334. }
  335. }else{
  336. obj.key = list[i].code ? list[i].code+'.1':'1'
  337. }
  338. return obj
  339. }else{
  340. if (list[i].level<3){
  341. if(list[i].children){
  342. if(list[i].children[0]){
  343. let obj = self.cascaderCheckData(val,list[i].children);
  344. if(obj){
  345. return obj
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. },
  353. //自动补位计算
  354. getListKey(dataList){
  355. let num = 0;
  356. for(let i=0;i<dataList.length;i++){
  357. let list = dataList[i].code.split('.');
  358. if(num === 0 && parseInt(list[list.length-1]) !== 1){
  359. return 1
  360. }else{
  361. if(num+1 === parseInt(list[list.length-1])){
  362. num = parseInt(list[list.length-1]);
  363. }else{
  364. return num+1
  365. }
  366. }
  367. }
  368. return num+1
  369. },
  370. //序号调整按钮
  371. codeButton(type){
  372. let obj = this.getListCode(this.addDialogForm.code,type,this.checkList);
  373. if(obj.type){
  374. this.$set(this.addDialogForm,'code',obj.value);
  375. }
  376. },
  377. getListCode(code,type,list){
  378. let codeList = code.split('.');
  379. let codeNum = parseInt(codeList[codeList.length-1]);
  380. let codeText = '';
  381. let obj = {type:false,value:""}
  382. if(!list[0]){
  383. return obj
  384. }
  385. if(type == 1){
  386. if(codeNum==1 || !list[0]){
  387. return obj
  388. }
  389. }else if(type == 2){
  390. let maxList = list[list.length-1].code.split('.')
  391. let maxCode = parseInt(maxList[maxList.length-1]);
  392. if(codeNum > maxCode){
  393. return obj
  394. }
  395. }
  396. for(let i=0;i<codeList.length-1;i++){
  397. if(i===0){
  398. codeText = codeText + codeList[i]
  399. }else{
  400. codeText = codeText +'.'+ codeList[i]
  401. }
  402. }
  403. let age = parseInt(codeNum);
  404. if(type == 1){
  405. age--
  406. for(age;age>0;age--){
  407. let counter = 0;
  408. for(let o=0;o<list.length;o++){
  409. let codeList = list[o].code.split('.');
  410. let code = parseInt(codeList[codeList.length-1]);
  411. if(code == age){
  412. counter++
  413. }
  414. }
  415. if(counter == 0){
  416. return {
  417. type:true,
  418. value:codeText?codeText+'.'+age:age+''
  419. }
  420. }
  421. }
  422. return obj;
  423. }else if(type == 2){
  424. age++
  425. for(age;age<999;age++){
  426. let counter = 0;
  427. for(let o=0;o<list.length;o++){
  428. let codeList = list[o].code.split('.');
  429. let code = parseInt(codeList[codeList.length-1]);
  430. if(code == age){
  431. counter++
  432. }
  433. }
  434. if(counter == 0){
  435. return {
  436. type:true,
  437. value:codeText?codeText+'.'+age:age+''
  438. }
  439. }
  440. }
  441. return obj;
  442. }
  443. },
  444. //选中同级数据
  445. getCodeButton(list,parentId,id){
  446. let self = this;
  447. for(let i=0;i<list.length;i++){
  448. if(list[i].id == parentId){
  449. if(list[i].children){
  450. let newList = JSON.parse(JSON.stringify(list[i].children))
  451. for(let o=0;o<newList.length;o++){
  452. if(newList[o].id == id){
  453. newList.splice(o,1)
  454. }
  455. }
  456. this.$set(this,'checkList',newList);
  457. return
  458. }
  459. }else{
  460. if (list[i].level<3){
  461. if(list[i].children){
  462. if(list[i].children[0]){
  463. self.getCodeButton(list[i].children,parentId,id)
  464. }
  465. }
  466. }
  467. }
  468. }
  469. },
  470. //删除
  471. delItem(row){
  472. let self = this;
  473. this.$confirm('是否确认删除?', "警告", {
  474. confirmButtonText: "确定",
  475. cancelButtonText: "取消",
  476. type: "warning"
  477. }).then(function() {
  478. checkOptionDelete(row.id).then( response => {
  479. self.msgSuccess(response.msg)
  480. self.getList();
  481. })
  482. }).then(() => {
  483. }).catch(() => {});
  484. },
  485. //批量删除
  486. allDel(){
  487. let self = this;
  488. if(!this.$refs.multipleTable.selection[0]){
  489. this.msgError('请勾选数据')
  490. return
  491. }
  492. this.$confirm('是否确认删除?', "警告", {
  493. confirmButtonText: "确定",
  494. cancelButtonText: "取消",
  495. type: "warning"
  496. }).then(function() {
  497. let list = self.$refs.multipleTable.selection;
  498. let ids = [];
  499. for(let i=0;i<list.length;i++){
  500. ids.push(list[i].id)
  501. }
  502. checkOptionBatchDelete(ids+'').then( response => {
  503. self.msgSuccess(response.msg);
  504. self.getList();
  505. })
  506. }).then(() => {
  507. }).catch(() => {});
  508. },
  509. /** 查询检查项选项列表 */
  510. getList() {
  511. this.loading = true;
  512. checkOptionList(this.queryParams).then( response => {
  513. this.$set(this,'tableData',JSON.parse(JSON.stringify(response.data)));
  514. let list = [{
  515. id:'0',
  516. name:"最上级",
  517. code:false,
  518. level:0,
  519. children:JSON.parse(JSON.stringify(response.data)),
  520. }]
  521. this.$set(this,'cascaderData',list);
  522. this.$set(this,'cascaderDataPrimitive',JSON.parse(JSON.stringify(list)));
  523. this.getCascaderData(this.cascaderData);
  524. this.$set(this,'total',response.total);
  525. this.loading = false;
  526. });
  527. },
  528. //联级选择器数据处理
  529. getCascaderData(list){
  530. let self = this;
  531. for(let i=0;i<list.length;i++){
  532. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  533. if(list[i].level == 0 || list[i].level == 1){
  534. self.getCascaderData(list[i].children)
  535. }else{
  536. delete list[i].children
  537. }
  538. }
  539. },
  540. //查询
  541. onSearch() {
  542. this.getList();
  543. },
  544. //重置
  545. resetForm() {
  546. this.$set(this.queryParams,'searchValue',null);
  547. this.$set(this,'total',0);
  548. this.onSearch();
  549. },
  550. //****************************************导入功能**************************************
  551. handleAvatarSuccess(res, file) {
  552. if(res.code == 200){
  553. this.getImportData.downFile = res.data.downFile
  554. this.getImportData.successNum = res.data.successNum
  555. this.getImportData.failureNum = res.data.failureNum
  556. // this.importOpen = false;
  557. // this.getList();
  558. }else{
  559. this.msgError(res.msg);
  560. }
  561. this.loading = false;
  562. },
  563. beforeAvatarUpload(file) {
  564. let type = false;
  565. console.log('file',file);
  566. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  567. if(file.size> 5250000){
  568. this.msgError('上传大小不能超过5M')
  569. return false
  570. }
  571. this.getImportData.textName = file.name;
  572. type = true;
  573. this.loading = true;
  574. }else{
  575. this.$message.error('只能上传xls/xlsx格式文件');
  576. type = false;
  577. }
  578. return type;
  579. },
  580. //导入页面关闭
  581. importOpenOff(){
  582. this.importOpen = false;
  583. this.getImportData.downFile = false;
  584. this.getImportData.successNum = 0;
  585. this.getImportData.failureNum = 0;
  586. this.getImportData.textName = "";
  587. },
  588. /** 导入按钮操作 */
  589. importButton(item){
  590. if(item.command == 1){
  591. // 下载模板
  592. this.download('/system/user/teacher/importTemplate', {}, `导入模板.xlsx`)
  593. }else if(item.command == 2){
  594. // 导入数据
  595. console.log('导入数据');
  596. this.importOpen = true;
  597. }
  598. },
  599. /** 当前时间 */
  600. getCurrentTime () {
  601. const yy = new Date().getFullYear()
  602. const mm = new Date().getMonth() + 1
  603. const dd = new Date().getDate()
  604. const hh = new Date().getHours()
  605. const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
  606. const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
  607. return yy + '-' + mm + '-' + dd
  608. },
  609. /** 导出按钮操作 */
  610. exportButton(item) {
  611. let self = this;
  612. this.currentDate=this.getCurrentTime()
  613. if(item.command == 1){
  614. self.$confirm(`确认导出全部数据?`, "提示", {
  615. confirmButtonText: "确定",
  616. cancelButtonText: "取消",
  617. type: "warning"
  618. }).then(async () => {
  619. self.download('/zd-security/checkOption/export/', {...self.queryParams}, '项目检查库.xlsx')
  620. }).catch(() => {})
  621. }else if(item.command == 2){
  622. let list = self.$refs.multipleTable.selection;
  623. let ids = [];
  624. for(let i=0;i<list.length;i++){
  625. ids.push(list[i].id)
  626. }
  627. console.log('list',list);
  628. console.log('ids',ids);
  629. if(ids.length>0) {
  630. self.$confirm(`确认导出选中数据?`, "提示", {
  631. confirmButtonText: "确定",
  632. cancelButtonText: "取消",
  633. type: "warning"
  634. }).then(async () => {
  635. let obj = {
  636. ids :ids.join(',')
  637. }
  638. self.download(`/zd-security/checkOption/export/`,obj, '项目检查库.xlsx')
  639. }).catch(() => {})
  640. }else {
  641. Message({
  642. message: "请选择要导出的数据",
  643. type: 'error'
  644. });
  645. }
  646. }
  647. },
  648. /** 下载模板操作 */
  649. importTemplate() {
  650. this.download('/system/user/teacher/importTemplate', {}, `导入模板.xlsx`)
  651. },
  652. /*下载失败列表*/
  653. failureExcel(){
  654. this.download('/system/user/teacher/importErrorData', {}, `失败报表.xlsx`)
  655. },
  656. /*===记录勾选数据===
  657. 需要再el-table 添加 :row-key="getRowKeys"
  658. 需要在selection 添加 :reserve-selection="true"
  659. */
  660. getRowKeys(row) {
  661. return row.id
  662. },
  663. // 单选
  664. select (selection, row) {
  665. if (selection.some(el => { return row.id === el.id })) {
  666. if (row.children) {
  667. this.setChildren(row.children, true)
  668. }
  669. } else {
  670. if (row.children) {
  671. this.setChildren(row.children, false)
  672. }
  673. }
  674. },
  675. // 全选
  676. selectAll (selection) {
  677. const isSelect = selection.some(el => {
  678. const tableDataIds = this.tableData.map(j => j.id)
  679. return tableDataIds.includes(el.id)
  680. })
  681. const isCancel = !this.tableData.every(el => {
  682. const selectIds = selection.map(j => j.id)
  683. return selectIds.includes(el.id)
  684. })
  685. if (isSelect) {
  686. selection.map(el => {
  687. if (el.children) {
  688. this.setChildren(el.children, true)
  689. }
  690. })
  691. }
  692. if (isCancel) {
  693. this.tableData.map(el => {
  694. if (el.children) {
  695. this.setChildren(el.children, false)
  696. }
  697. })
  698. }
  699. },
  700. setChildren (children, type) {
  701. children.map(j => {
  702. this.toggleSelection(j, type)
  703. if (j.children) {
  704. this.setChildren(j.children, type)
  705. }
  706. })
  707. },
  708. toggleSelection (row, select) {
  709. if (row) {
  710. this.$nextTick(() => {
  711. this.$refs.multipleTable && this.$refs.multipleTable.toggleRowSelection(row, select)
  712. })
  713. }
  714. },
  715. },
  716. }
  717. </script>
  718. <style scoped lang="scss">
  719. .checkItemLibrary{
  720. flex:1;
  721. display: flex!important;
  722. flex-direction: column;
  723. overflow: hidden;
  724. .title-box{
  725. padding-top:20px;
  726. .form-box{
  727. border-bottom:1px solid #E0E0E0;
  728. .form-dropdown-box{
  729. display: flex;
  730. margin:0;
  731. padding:0 10px;
  732. cursor: pointer;
  733. height:40px;
  734. img:nth-child(1){
  735. width:16px;
  736. height:16px;
  737. margin-top:12px;
  738. }
  739. p{
  740. width:47px;
  741. text-align: center;
  742. font-size:14px;
  743. margin:0;
  744. line-height:40px;
  745. }
  746. img:nth-child(3){
  747. width:10px;
  748. height:6px;
  749. margin-top:17px;
  750. }
  751. }
  752. }
  753. }
  754. .content-box{
  755. flex:1;
  756. overflow: hidden;
  757. display: flex;
  758. flex-direction: column;
  759. padding:20px;
  760. }
  761. }
  762. </style>
  763. <style lang="scss">
  764. .checkItemLibrary-dialog-box{
  765. .teacher-import-dialog-upLoad-box{
  766. .el-upload{
  767. width:450px;
  768. margin:0 55px;
  769. .el-upload-dragger{
  770. width:450px;
  771. .el-icon-upload{
  772. font-size:100px;
  773. color:#CBE6FE;
  774. }
  775. .el-upload__text{
  776. margin-top:20px;
  777. }
  778. }
  779. }
  780. .el-upload__tip{
  781. margin-left:60px;
  782. font-size:14px;
  783. margin-top:10px;
  784. }
  785. .el-upload-text-box{
  786. background: #F5F5F5;
  787. border-radius: 10px;
  788. margin:15px 30px 0;
  789. padding:0 20px 15px;
  790. overflow: hidden;
  791. *{
  792. margin:0;
  793. }
  794. .img-text-box{
  795. display: flex;
  796. margin-top:15px;
  797. img{
  798. width:16px;
  799. height:16px;
  800. margin-right:13px;
  801. }
  802. p{
  803. height:16px;
  804. line-height:16px;
  805. font-size:12px;
  806. }
  807. }
  808. .text-p{
  809. margin-top:15px;
  810. margin-left:29px;
  811. height:16px;
  812. line-height:16px;
  813. font-size:12px;
  814. }
  815. }
  816. }
  817. .teacher-import-dialog-button-box{
  818. display: flex;
  819. width:190px;
  820. margin:0 auto;
  821. p{
  822. width:70px;
  823. height:30px;
  824. line-height:30px;
  825. font-size:14px;
  826. margin:0 auto;
  827. }
  828. }
  829. .teacher-import-dialog-position-box{
  830. width:100%;
  831. height:100%;
  832. position: absolute;
  833. top:0;
  834. left:0;
  835. z-index: 999;
  836. background: rgba(255,255,255,0.4);
  837. border-radius:20px;
  838. }
  839. .code-max-box{
  840. display: flex;
  841. .code-button-box{
  842. display: flex;
  843. flex-direction: column;
  844. margin-left:8px;
  845. p{
  846. width:40px;
  847. text-align: center;
  848. line-height:19px;
  849. font-size:14px;
  850. cursor: pointer;
  851. color:#d8d8d8;
  852. }
  853. p:nth-child(1){
  854. border:1px solid #d8d8d8;
  855. border-top-left-radius: 4px;
  856. border-top-right-radius: 4px;
  857. }
  858. p:nth-child(2){
  859. border-bottom:1px solid #d8d8d8;
  860. border-left:1px solid #d8d8d8;
  861. border-right:1px solid #d8d8d8;
  862. border-bottom-left-radius: 4px;
  863. border-bottom-right-radius: 4px;
  864. }
  865. p:hover{
  866. color:#fff;
  867. background-color: #d8d8d8;
  868. }
  869. }
  870. }
  871. }
  872. </style>