index.vue 14 KB

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