index.vue 29 KB

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