index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <!--设备检查配置-->
  2. <template>
  3. <div class="app-container approval_handle">
  4. <div class="approval_handle-page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" style="margin-top:20px;" :inline="true">
  6. <el-form-item label="类型:" prop="checkLevel">
  7. <el-select v-model="queryParams.hazardType" placeholder="请选择类型">
  8. <el-option
  9. v-for="item in dangerArr"
  10. :key="item.dictValue"
  11. :label="item.dictLabel"
  12. :value="item.dictValue">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="关键字" prop="name">
  17. <el-input
  18. v-model="queryParams.searchValue"
  19. placeholder="名称/型号"
  20. clearable
  21. maxLength="30"
  22. size="small"
  23. />
  24. </el-form-item>
  25. <el-form-item>
  26. <p class="inquire-button-one" @click="handleQuery">查询</p>
  27. <p class="reset-button-one" @click="resetQuery">重置</p>
  28. </el-form-item>
  29. <el-form-item style="float: right;">
  30. <p class="inquire-button-one" v-hasPermi="['check:device:add']" style="width:120px;" @click="handleClick('','','add')">+ 新增检查内容</p>
  31. </el-form-item>
  32. </el-form>
  33. <el-table border v-loading="loading" :data="tableData">
  34. <el-table-column label="序号" width="100" align="left" type="index"/>
  35. <el-table-column label="类型" align="left" prop="dictLabel"/>
  36. <el-table-column label="名称" align="left" prop="anotherName"></el-table-column>
  37. <el-table-column label="型号" align="left" prop="anotherCode"></el-table-column>
  38. <el-table-column label="检查项目数" align="left" prop="checkNum"></el-table-column>
  39. <el-table-column label="编辑人" align="left" prop="createName"></el-table-column>
  40. <el-table-column label="编辑时间" align="left" prop="createTimeStr"></el-table-column>
  41. <el-table-column label="操作" width="180">
  42. <template slot-scope="scope">
  43. <div class="table-button-box">
  44. <p class="table-button-null"></p>
  45. <p class="table-button-p" v-hasPermi="['check:device:query']" @click="handleClick('',scope.row,'detail')">详情</p>
  46. <p class="table-button-p" v-hasPermi="['check:device:edit']" @click="handleClick('',scope.row,'edit')">编辑</p>
  47. <p class="table-button-p" v-hasPermi="['check:device:remove']" @click="handleClick('',scope.row,'delete')">删除</p>
  48. <p class="table-button-null"></p>
  49. </div>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <pagination :page-sizes="[20, 30, 40, 50]"
  54. :total="total"
  55. layout="total, prev, pager, next, sizes, jumper"
  56. :page.sync="queryParams.pageNum"
  57. :limit.sync="queryParams.pageSize"
  58. @pagination="getList"
  59. />
  60. </div>
  61. <!--添加窗口-->
  62. <el-dialog :title="addDialogTitle" :visible.sync="addDialogType" @close="addDialogOff" width="780px" append-to-body class="checkItemLibrary-dialog-box"
  63. :close-on-click-modal="false">
  64. <el-form ref="addDialogForm" :model="addDialogForm" :rules="rules" label-width="120px">
  65. <el-form-item label="检查内容:" prop="joinHazardReid">
  66. <el-select v-model="addDialogForm.joinHazardReid" clearable placeholder="请选择检查项" :disabled="isDetail" style="width:548px;">
  67. <el-option
  68. v-for="item in materialTypeList"
  69. :key="item.id"
  70. :label="item.anotherName"
  71. :value="item.id">
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. <div class="small_title">对应检查项目</div>
  76. <el-form-item label="检查类目" prop="joinCheckOpList" v-if="!isDetail">
  77. <el-cascader
  78. style="width:548px;"
  79. v-model="addDialogForm.joinCheckOpList"
  80. :options="cascaderData"
  81. :props="{ multiple: true, value: 'id', label: 'labelName',emitPath:false }"
  82. @change="cascaderCheck">
  83. <template slot-scope="{data}">
  84. <el-tooltip :content="data.labelName" v-if="data.labelName.length>22">
  85. <p style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  86. </el-tooltip>
  87. <p v-else style="max-width:300px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;">{{data.labelName}}</p>
  88. </template>
  89. </el-cascader>
  90. </el-form-item>
  91. <div style="height: 300px;overflow-y: auto">
  92. <el-form-item label="">
  93. <el-tree
  94. ref="tree"
  95. :data="cascaderTreeData"
  96. :props="defaultProps"
  97. show-checkbox
  98. node-key="id"
  99. default-expand-all
  100. :default-checked-keys="cascaderCheckedData"
  101. >
  102. </el-tree>
  103. </el-form-item>
  104. </div>
  105. </el-form>
  106. <div slot="footer" class="dialog-footer dialog-footer-box" style="display: flex">
  107. <p class="dialog-footer-button-null"></p>
  108. <p class="dialog-footer-button-info" @click="addDialogOff">取消</p>
  109. <p class="dialog-footer-button-primary" @click="upDataButton">确定</p>
  110. <p class="dialog-footer-button-null"></p>
  111. </div>
  112. </el-dialog>
  113. </div>
  114. </template>
  115. <script>
  116. import { dangerList, gasApplyDetail, gasApplyList } from '@/api/gasManage3_0/gasManage'
  117. import { getToken } from "@/utils/auth";
  118. import {
  119. checkOptionAdd,
  120. checkOptionList,
  121. checkOptionUpdate,
  122. checkDeviceList,
  123. checkDeviceAdd,
  124. inspectContentList, checkDeviceDetail, checkDeviceEdit, checkDeviceDelete, checkOptionDelete
  125. } from '@/api/safetyCheck'
  126. import { delCertificate } from '@/api/exam/certificate'
  127. import { delHxpChemicalInfo } from '@/api/medicUniversity-3_1'
  128. export default {
  129. name: "Approval",
  130. components: {
  131. },
  132. data() {
  133. return {
  134. //页面状态
  135. pageType:1,
  136. loading:false,
  137. headers: {
  138. Authorization: "Bearer " + getToken()
  139. },
  140. // 查询参数
  141. queryParams: {
  142. pageNum: 1,
  143. pageSize:20,
  144. hazardType:'',
  145. searchValue:'',
  146. },
  147. total:0,
  148. tableData:[{}],
  149. dateRange:[],
  150. pageData2:{},
  151. addDialogTitle:'新增检查项',
  152. addDialogType:false,
  153. addDialogForm:{
  154. joinHazardReid:'',
  155. joinCheckOpList:[],
  156. },
  157. //检查项
  158. cascaderData:[],
  159. cascaderTreeData:[],
  160. cascaderDataPrimitive:[],
  161. dangerArr:[],//危险源类型
  162. materialTypeList:[],//检查内容
  163. // 表单校验
  164. rules: {
  165. joinCheckOpList: [
  166. { required: true, message: "请选择", trigger: "blur" },
  167. { required: true, message: "请选择", validator: this.spaceJudgment, trigger: "blur" }
  168. ],
  169. joinHazardReid: [
  170. { required: true, message: "请输入检查项目内容", trigger: "blur" },
  171. { required: true, message: "请输入检查项目内容", validator: this.spaceJudgment, trigger: "blur" }
  172. ],
  173. },
  174. defaultProps: {
  175. children: 'children',
  176. label: 'labelName'
  177. },
  178. cascaderCheckedData:[],//检查类目树回显
  179. isDetail:false,
  180. }
  181. },
  182. methods: {
  183. handleClick(index,row,doType){
  184. let _this=this;
  185. if(doType=='add'){//新增
  186. this.isDetail=false;
  187. this.$set(this,'addDialogType',true);
  188. this.$set(this,'addDialogTitle','新增检查项');
  189. this.inspectContentList()//检查内容
  190. this.$nextTick(function () {
  191. //Dom更新完毕
  192. this.$refs.tree.setCheckedKeys([]);
  193. });
  194. }else if(doType=='detail'){//详情
  195. this.isDetail=true;
  196. this.$set(this,'addDialogType',true);
  197. this.$set(this,'addDialogTitle','编辑检查项');
  198. this.getInfo(row.id)
  199. this.inspectContentList(row.id)//检查内容
  200. this.$nextTick(function () {
  201. //Dom更新完毕
  202. this.$refs.tree.setCheckedKeys([]);
  203. });
  204. }else if(doType=='edit'){//编辑
  205. this.isDetail=false;
  206. this.$set(this,'addDialogType',true);
  207. this.$set(this,'addDialogTitle','编辑检查项');
  208. this.getInfo(row.id)
  209. this.inspectContentList(row.id)//检查内容
  210. this.$nextTick(function () {
  211. //Dom更新完毕
  212. this.$refs.tree.setCheckedKeys([]);
  213. });
  214. }else if(doType=='delete'){//删除
  215. this.$confirm('是否确认删除?', "警告", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning"
  219. }).then(() => {
  220. checkDeviceDelete(row.id).then(response => {
  221. if(response.code == 200){
  222. this.getList();
  223. this.msgSuccess("删除成功");
  224. }
  225. });
  226. }).catch(() => {});
  227. }
  228. },
  229. //添加页面关闭
  230. addDialogOff(){
  231. this.$set(this.addDialogForm,'joinCheckOpList',null);
  232. this.$set(this.addDialogForm,'joinHazardReid','');
  233. this.$set(this,'addDialogType',false);
  234. },
  235. //联级选中
  236. cascaderCheck(val){
  237. },
  238. /** 搜索按钮操作 */
  239. handleQuery() {
  240. this.queryParams.pageNum = 1;
  241. this.getList();
  242. },
  243. /** 重置按钮操作 */
  244. resetQuery() {
  245. this.queryParams.searchValue = "";
  246. this.queryParams.hazardType='',
  247. this.handleQuery();
  248. },
  249. /** 查询检查项选项列表 */
  250. checkOptionList() {
  251. this.loading = true;
  252. checkOptionList(this.queryParams).then( response => {
  253. let list=JSON.parse(JSON.stringify(response.data))
  254. this.$set(this,'cascaderData',list);
  255. this.$set(this,'cascaderTreeData',JSON.parse(JSON.stringify(list)));
  256. this.$set(this,'cascaderDataPrimitive',JSON.parse(JSON.stringify(list)));
  257. this.getCascaderData(this.cascaderData);
  258. this.getCascaderTreeData(this.cascaderTreeData);
  259. this.loading = false;
  260. });
  261. },
  262. //联级选择器数据处理
  263. getCascaderData(list){
  264. let self = this;
  265. for(let i=0;i<list.length;i++){
  266. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  267. if(list[i].level == 1 || list[i].level == 2 || list[i].level == 3){
  268. self.getCascaderData(list[i].children)
  269. }else{
  270. delete list[i].children
  271. }
  272. }
  273. },
  274. //树形选择器数据处理
  275. getCascaderTreeData(list){
  276. let self = this;
  277. for(let i=0;i<list.length;i++){
  278. list[i].labelName = list[i].code? list[i].code +' '+ list[i].name:list[i].name
  279. list[i].disabled = true;
  280. if(list[i].level == 1 || list[i].level == 2 || list[i].level == 3){
  281. self.getCascaderTreeData(list[i].children)
  282. }else{
  283. delete list[i].children
  284. }
  285. }
  286. },
  287. //获取危险源类型
  288. dangerList(){
  289. let _this=this;
  290. dangerList().then( response => {
  291. let res=response.rows;
  292. _this.dangerArr=res;
  293. });
  294. },
  295. //检查内容
  296. inspectContentList(joinHazardReid){
  297. let _this=this;
  298. if(joinHazardReid){//编辑的时候
  299. inspectContentList({joinHazardReid:joinHazardReid}).then( response => {
  300. let res=response.data;
  301. _this.materialTypeList=res;
  302. });
  303. }else{//新增的时候
  304. inspectContentList().then( response => {
  305. let res=response.data;
  306. _this.materialTypeList=res;
  307. });
  308. }
  309. },
  310. //详情
  311. getInfo(id){
  312. let _this=this;
  313. checkDeviceDetail(({id:id})).then( response => {
  314. let res=response.data;
  315. if(response.code==200){
  316. let list=[];
  317. this.addDialogForm.joinHazardReOldid=res.hazardId;
  318. this.addDialogForm.joinHazardReid=res.hazardId;
  319. res.checkList.forEach(function(item) {
  320. list.push(item.joinCheckOpid)
  321. })
  322. this.addDialogForm.joinCheckOpList=list
  323. this.cascaderCheckedData=list
  324. }
  325. });
  326. },
  327. //列表
  328. getList(){
  329. let _this=this;
  330. checkDeviceList(_this.queryParams).then( response => {
  331. let res=response.data.records;
  332. _this.tableData=res;
  333. _this.total=response.data.total;
  334. });
  335. },
  336. //新增编辑
  337. upDataButton(){
  338. this.$refs["addDialogForm"].validate(valid => {
  339. if (valid) {
  340. if(this.addDialogForm.joinHazardReOldid){
  341. //编辑
  342. let obj={
  343. joinHazardReOldid:JSON.parse(JSON.stringify(this.addDialogForm)).joinHazardReOldid,
  344. joinHazardReid:JSON.parse(JSON.stringify(this.addDialogForm)).joinHazardReid,
  345. joinCheckOpList:JSON.parse(JSON.stringify(this.addDialogForm)).joinCheckOpList,
  346. }
  347. checkDeviceEdit(obj).then( response => {
  348. this.msgSuccess(response.msg)
  349. this.addDialogOff();
  350. this.getList();
  351. this.inspectContentList()
  352. })
  353. }else{
  354. //新增
  355. let obj={
  356. joinHazardReid:JSON.parse(JSON.stringify(this.addDialogForm)).joinHazardReid,
  357. joinCheckOpList:JSON.parse(JSON.stringify(this.addDialogForm)).joinCheckOpList,
  358. }
  359. checkDeviceAdd(obj).then( response => {
  360. this.msgSuccess(response.msg)
  361. this.addDialogOff();
  362. this.getList();
  363. this.inspectContentList()
  364. })
  365. }
  366. }
  367. })
  368. },
  369. },
  370. mounted() {
  371. this.checkOptionList();
  372. this.inspectContentList()
  373. this.dangerList()
  374. this.getList()
  375. }
  376. };
  377. </script>
  378. <style scoped lang="scss">
  379. .approval_handle {
  380. display: flex!important;
  381. flex-direction: column;
  382. .goods-category-cascader-stocking-page .el-cascader-menu:nth-of-type(1) .el-checkbox__input {
  383. display: none !important;
  384. }
  385. .approval_handle-page{
  386. flex:1;
  387. display: flex!important;
  388. flex-direction: column;
  389. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  390. padding:20px 20px 20px!important;
  391. border-radius:10px;
  392. .button-box{
  393. width:200px;
  394. display: flex;
  395. }
  396. }
  397. }
  398. .el-dialog__body{
  399. padding: 20px 0!important;
  400. }
  401. .small_title{
  402. width: 100%;
  403. height: 40px;
  404. background: #F5F5F5;
  405. font-size: 16px;
  406. font-family: Microsoft YaHei-Regular, Microsoft YaHei;
  407. font-weight: 400;
  408. color: #0045AF;
  409. line-height: 40px;
  410. padding-left: 50px;
  411. margin-bottom:20px;
  412. }
  413. </style>