safetyInfoConfig.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <!--安全信息配置-->
  2. <template>
  3. <div class=" safetyInfoConfig">
  4. <div class="title-box">
  5. <div @click="titleClick(1)">
  6. <p>安全类目</p>
  7. <p></p>
  8. </div>
  9. <div @click="titleClick(2)">
  10. <p>信息配置</p>
  11. <p class="bottom-p-color"></p>
  12. </div>
  13. </div>
  14. <div class="config_main">
  15. <div class="config_main_l scrollbar-box">
  16. <div class="config_main_l_title">
  17. <img src="@/assets/ZDimages/icon_xxpz_aqxxlm.png">
  18. 安全信息类目
  19. </div>
  20. <div :class='currentIndex==index?"active":""' class="config_main_l_li" v-for="(item,index) in tabsList" :key="index" @click="handleTabClick(item,index)">{{item.classifyName}}</div>
  21. </div>
  22. <p class="config_main_border"></p>
  23. <div class="approval_handle-page">
  24. <p>
  25. <el-button
  26. style="float: right;margin-bottom: 20px"
  27. v-hasPermi="['laboratory:classify:add']"
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleClick('','','add')"
  33. >新增</el-button>
  34. </p>
  35. <el-table border v-loading="loading" :data="tableData">
  36. <el-table-column label="" align="left" class-name="small-padding fixed-width" width="120">
  37. <template slot-scope="scope">
  38. <el-input
  39. onkeyup="value=value.replace(/[^\d]/g,'')"
  40. class="serial"
  41. v-model="scope.row.sort"
  42. @change="categorySort(scope.row)"
  43. maxLength="3"
  44. placeholder="序号">
  45. </el-input>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="信息名称" align="left" prop="infoName"/>
  49. <el-table-column label="公共信息" align="left">
  50. <template slot-scope="scope">
  51. <el-switch
  52. @click.native="categoryShow(scope.row)"
  53. class="category-switch captcha-img"
  54. :active-value="2"
  55. :inactive-value="1"
  56. active-color="#FF9900"
  57. inactive-color="#999"
  58. v-model="scope.row.isCollective"
  59. active-text="是"
  60. inactive-text="否"
  61. disabled
  62. ></el-switch>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="添加人" align="left" prop="createBy"/>
  66. <el-table-column label="添加时间" align="left" prop="createTime"/>
  67. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
  68. <template slot-scope="scope">
  69. <div class="button-box">
  70. <p class="table-min-button"
  71. v-hasPermi="['laboratory:classify:edit']"
  72. @click="handleClick('',scope.row,'edit')"
  73. >编辑</p>
  74. <p class="table-min-button"
  75. v-hasPermi="['laboratory:classify:remove']"
  76. @click="handleClick('',scope.row,'delete')"
  77. >删除</p>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <pagination :page-sizes="[20, 30, 40, 50]"
  83. :total="total"
  84. layout="total, prev, pager, next, sizes, jumper"
  85. :page.sync="queryParams.pageNum"
  86. :limit.sync="queryParams.pageSize"
  87. @pagination="getList"
  88. />
  89. </div>
  90. </div>
  91. <!-- 添加或修改安全分级对话框 -->
  92. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :before-close="closeDialog">
  93. <el-form ref="form" :model="form" :rules="rules" label-width="80px" >
  94. <el-form-item label="信息名称" prop="infoName">
  95. <el-input v-model="form.infoName" maxlength="30" placeholder="请输入名称" style="width:320px;"/>
  96. </el-form-item>
  97. <el-form-item label="信息类目" prop="infoClassifyId" class="form-item">
  98. <el-select placeholder="请选择类目" v-model="form.infoClassifyId" style="width:320px;" @change="categoryClick()">
  99. <el-option
  100. v-for="dict in categoryList"
  101. :key="dict.id"
  102. :label="dict.classifyName"
  103. :value="dict.id"
  104. ></el-option>
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="信息类型">
  108. <el-input v-model="form.infoTypeName" placeholder="" disabled style="width:320px;"/>
  109. </el-form-item>
  110. <el-form-item label="信息内容" prop="infoContent" v-if="form.infoType==1">
  111. <el-input type="textarea" v-model="form.infoContent" maxlength="200" placeholder="请输入内容" style="width:320px;"/>
  112. </el-form-item>
  113. <el-form-item label="信息内容" prop="infoContent" v-if="form.infoType==2">
  114. <el-upload
  115. class="certificate-avatar-uploader"
  116. :action="uploadImgUrl"
  117. :show-file-list="false"
  118. :on-success="handleAvatarSuccess"
  119. :headers="headers"
  120. :before-upload="beforeAvatarUpload">
  121. <div style="display: flex;">
  122. <img v-if="form.infoContent" :src="form.infoContent" style="width: 80px;height: 80px;margin-right: 10px">
  123. <i v-if="!form.infoContent" class="el-icon-plus avatar-uploader-icon"></i>
  124. </div>
  125. </el-upload>
  126. </el-form-item>
  127. <P v-if="form.infoType==2" style="margin-left: 80px">图片最大上传630*78,建议尺寸58*78</P>
  128. </el-form>
  129. <div slot="footer" class="dialog-footer">
  130. <el-button type="primary" @click="submitForm">确 定</el-button>
  131. <el-button @click="cancel">取 消</el-button>
  132. </div>
  133. </el-dialog>
  134. </div>
  135. </template>
  136. <script>
  137. import { getToken } from "@/utils/auth";
  138. import {
  139. infoCategoryList,
  140. infoConfigAdd, infoConfigList, infoConfigPut, infoConfigDelete, infoCategoryPut
  141. } from '@/api/laboratory/safetyInfo'
  142. import safetyInfoConfig from "./safetyInfoConfig.vue"
  143. import { listHazard } from '@/api/permissionRequired'
  144. export default {
  145. name: "Approval",
  146. components: {
  147. safetyInfoConfig
  148. },
  149. data() {
  150. return {
  151. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  152. activeName: '',
  153. // 弹出层标题
  154. title: "",
  155. // 是否显示弹出层
  156. open: false,
  157. //页面状态
  158. pageType:1,
  159. loading:false,
  160. headers: {
  161. Authorization: "Bearer " + getToken()
  162. },
  163. // 查询参数
  164. queryParams: {
  165. pageNum: 1,
  166. pageSize:20,
  167. infoClassifyId:'',
  168. },
  169. total:0,
  170. tableData:[],
  171. dateRange:[],
  172. pageData2:{},
  173. tabsList:[],
  174. categoryList:[],
  175. // 表单参数
  176. form: {
  177. infoName:'',
  178. infoClassifyId:'',
  179. infoType:'',
  180. infoTypeName:'',
  181. infoContent:'',
  182. isCollective:'',
  183. },
  184. currentIndex:0,
  185. // 表单校验
  186. rules: {
  187. infoName: [
  188. { required: true, message: "请输入名称", trigger: "blur" },
  189. ],
  190. infoClassifyId: [
  191. { required: true, message: "请选择类目", trigger: "blur" },
  192. ],
  193. infoContent: [
  194. { required: true, message: "请添加信息内容", trigger: "blur" },
  195. ],
  196. }
  197. };
  198. },
  199. methods: {
  200. titleClick(type){
  201. this.$parent.titleClick(type);
  202. },
  203. closeDialog(){
  204. this.$refs['form'].clearValidate()
  205. this.open=false
  206. },
  207. handleTabClick(item,index){
  208. this.currentIndex = index
  209. this.queryParams.infoClassifyId=item.id;
  210. this.getList()
  211. },
  212. handleClick(index,row,doType){
  213. let self=this;
  214. if(doType=='add'){//添加
  215. this.title='新增安全信息';
  216. delete this.form.id
  217. this.form.infoName='';
  218. this.form.infoClassifyId='';
  219. this.form.infoType='';
  220. this.form.infoTypeName='';
  221. this.form.infoContent='';
  222. this.open = true;
  223. }else if(doType=='edit'){//编辑
  224. this.title='编辑安全信息';
  225. this.form.id=row.id
  226. this.form.infoName=row.infoName
  227. this.form.infoClassifyId=row.infoClassifyId
  228. this.form.infoContent=row.infoContent
  229. this.form.infoType=row.infoType
  230. this.form.infoTypeName=row.infoType==1?'文字':'图片';
  231. this.open = true;
  232. }else if(doType=='deploy'){//信息牌配置
  233. self.pageType=2;
  234. }else if(doType=='delete'){//删除
  235. this.$confirm('确认要删除吗?', "警告", {
  236. confirmButtonText: "确定",
  237. cancelButtonText: "取消",
  238. type: "warning"
  239. }).then(() => {
  240. // 确定
  241. infoConfigDelete(row.id).then(response => {
  242. self.msgSuccess(response.msg);
  243. self.getList();
  244. });
  245. }).catch(function() {});
  246. }else if(doType=='back'){//返回
  247. self.pageType=1;
  248. }
  249. },
  250. categorySort(row){
  251. let obj={
  252. id:row.id,
  253. sort:row.sort,
  254. }
  255. infoConfigPut(obj).then( response => {
  256. this.msgSuccess("修改成功");
  257. this.open = false;
  258. this.getList();
  259. });
  260. },
  261. categoryShow(row){
  262. let obj={
  263. id:row.id,
  264. isCollective:row.isCollective==1?2:1,
  265. }
  266. infoConfigPut(obj).then( response => {
  267. this.msgSuccess("修改成功");
  268. this.open = false;
  269. this.getList();
  270. });
  271. },
  272. categoryClick(){
  273. let _this=this;
  274. this.form.infoContent='';
  275. this.categoryList.forEach(function(item) {
  276. if(item.id==_this.form.infoClassifyId){
  277. _this.form.infoTypeName=item.classifyType==1?'文字':'图片';
  278. _this.form.infoType=item.classifyType;
  279. }
  280. })
  281. },
  282. /** 搜索按钮操作 */
  283. handleQuery() {
  284. this.queryParams.pageNum = 1;
  285. this.getList();
  286. },
  287. /** 重置按钮操作 */
  288. resetQuery() {
  289. this.handleQuery();
  290. },
  291. /** 取消按钮 */
  292. cancel() {
  293. this.$refs['form'].clearValidate()
  294. this.open = false;
  295. },
  296. /** 提交按钮 */
  297. submitForm() {
  298. this.$refs["form"].validate(valid => {
  299. if (valid) {
  300. if (this.form.id != null) {
  301. infoConfigPut(this.form).then( response => {
  302. this.msgSuccess("修改成功");
  303. this.open = false;
  304. this.getList();
  305. });
  306. } else {
  307. infoConfigAdd(this.form).then( response => {
  308. this.msgSuccess("新增成功");
  309. this.open = false;
  310. this.getList();
  311. });
  312. }
  313. }
  314. });
  315. },
  316. //上传
  317. handleAvatarSuccess(res, file) {
  318. this.form.infoContent = res.data.url;
  319. this.$forceUpdate()
  320. },
  321. beforeAvatarUpload(file) {
  322. return new Promise((resolve, reject) => {
  323. if (file.type == 'image/png') {
  324. let reader = new FileReader()
  325. reader.readAsDataURL(file) // 必须用file.raw
  326. reader.onload = e => { // 让页面中的img标签的src指向读取的路径
  327. let img = e.target.result;
  328. const image = new Image()
  329. image.src=img
  330. image.onload = _=>{
  331. console.log(image.width)
  332. console.log(image.height)
  333. if(image.width <= 630 && image.height <= 78){
  334. resolve()
  335. }else{
  336. this.$message.error('尺寸限制为最大630*78px,支持PNG格式')
  337. reject();
  338. }
  339. }
  340. }
  341. }else{
  342. this.$message.error('请上传PNG格式');
  343. reject();
  344. }
  345. })
  346. },
  347. //获取危险源列表
  348. getCategory(){
  349. listHazard({}).then(response=>{
  350. this.$set(this,'categoryList',response.data);
  351. })
  352. },
  353. //查询信息类目列表
  354. getCategoryList(){
  355. let _this=this;
  356. let obj={
  357. pageNum: 1,
  358. pageSize:100,
  359. isShow:1,
  360. remark:'sort',
  361. }
  362. infoCategoryList(obj).then( response => {
  363. let res=response.rows;
  364. if(response.code==200){
  365. if(res){
  366. _this.tabsList=res;
  367. _this.categoryList=res;
  368. _this.activeName=response.rows[0].id+''
  369. _this.queryParams.infoClassifyId=response.rows[0].id;
  370. this.getList()
  371. }
  372. }
  373. });
  374. },
  375. getList(){
  376. let _this=this;
  377. infoConfigList(_this.queryParams).then( response => {
  378. let res=response.rows;
  379. _this.tableData=res;
  380. _this.total=response.total;
  381. });
  382. },
  383. },
  384. mounted() {
  385. this.getCategoryList()
  386. }
  387. };
  388. </script>
  389. <style scoped lang="scss">
  390. .safetyInfoConfig {
  391. overflow: hidden;
  392. flex:1;
  393. display: flex!important;
  394. flex-direction: column;
  395. .title-box{
  396. display: flex;
  397. border-bottom:1px solid #E0E0E0;
  398. margin-bottom:20px;
  399. div{
  400. height:80px;
  401. margin-right:20px;
  402. cursor: pointer;
  403. p:nth-child(1){
  404. font-size:18px;
  405. text-align: center;
  406. padding:0 20px;
  407. margin-top:26px;
  408. }
  409. p:nth-child(2){
  410. width:40px;
  411. height:4px;
  412. border-radius:40px;
  413. margin:12px auto;
  414. }
  415. .top-p-color{
  416. color: #0045AF;
  417. }
  418. .bottom-p-color{
  419. background: #0045AF;
  420. }
  421. }
  422. .buttonTitleColorA{
  423. color:#0045AF;
  424. }
  425. .buttonTitleColorB{
  426. color:#999999;
  427. }
  428. }
  429. .config_main{
  430. overflow: hidden;
  431. flex:1;
  432. display: flex;
  433. overflow: hidden;
  434. .config_main_l{
  435. flex: 1;
  436. padding-left: 42px;
  437. padding-top: 20px;
  438. .config_main_l_title{
  439. font-size: 16px;
  440. font-weight: 400;
  441. color: #0183FA;
  442. >img{
  443. width: 16px;
  444. height: 13px;
  445. margin-right: 12px;
  446. }
  447. }
  448. .config_main_l_li{
  449. font-size: 14px;
  450. font-family: Microsoft YaHei-Regular, Microsoft YaHei;
  451. font-weight: 400;
  452. color: #333333;
  453. line-height: 68px;
  454. cursor: pointer;
  455. }
  456. .active{
  457. color: #0183FA;
  458. }
  459. }
  460. .config_main_border{
  461. border-right: 1px dashed #A2A2A2;
  462. margin: 20px 35px 36px 0;
  463. }
  464. /*表格*/
  465. .approval_handle-page{
  466. display: flex!important;
  467. flex-direction: column;
  468. width: 1264px;
  469. padding:0px 20px 20px!important;
  470. .button-box{
  471. width:200px;
  472. display: flex;
  473. }
  474. }
  475. }
  476. }
  477. </style>
  478. <style lang="scss">
  479. .category-switch .el-switch__label {
  480. position: absolute;
  481. display: none;
  482. color: #fff !important;
  483. }
  484. .category-switch .el-switch__label--right span {
  485. margin-left: 10px;
  486. }
  487. .category-switch .el-switch__label--left {
  488. z-index: 1;
  489. }
  490. .category-switch .el-switch__label--left span {
  491. margin-left: 24px;
  492. }
  493. .category-switch .el-switch__label.is-active {
  494. display: block;
  495. }
  496. .category-switch.el-switch .el-switch__core,
  497. .el-switch .el-switch__label {
  498. width: 60px !important;
  499. margin: 0;
  500. }
  501. </style>