123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- <!--安全信息类目-->
- <template>
- <div class="app-container approval_handle">
- <div class="tab-title">
- <div class="tab-title-l">
- <template>
- <el-tabs v-model="activeName" @tab-click="handleTabClick">
- <el-tab-pane :label="item.classifyName" :name="item.id+''" v-for="item in tabsList"></el-tab-pane>
- </el-tabs>
- </template>
- </div>
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleClick('','','add')"
- >新增</el-button>
- </div>
- <div class="approval_handle-page" v-if="pageType == 1">
- <el-table border v-loading="loading" :data="tableData">
- <el-table-column label="序号" width="100" align="left" type="index"/>
- <el-table-column label="信息名称" align="left" prop="infoName"/>
- <el-table-column label="公共信息" align="left">
- <template slot-scope="scope">
- <el-switch
- @click.native="categoryShow(scope.row)"
- class="category-switch captcha-img"
- :active-value="2"
- :inactive-value="1"
- active-color="#FF9900"
- inactive-color="#999"
- v-model="scope.row.isCollective"
- active-text="是"
- inactive-text="否"
- disabled
- ></el-switch>
- </template>
- </el-table-column>
- <el-table-column label="添加人" align="left" prop="createBy"/>
- <el-table-column label="添加时间" align="left" prop="createTime"/>
- <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
- <template slot-scope="scope">
- <div class="button-box">
- <p class="table-min-button"
- @click="handleClick('',scope.row,'edit')"
- >编辑</p>
- <p class="table-min-button"
- @click="handleClick('',scope.row,'delete')"
- >删除</p>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <pagination :page-sizes="[20, 30, 40, 50]"
- :total="total"
- layout="total, prev, pager, next, sizes, jumper"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- </div>
- <safety-Info-Config v-if="pageType == 2"></safety-Info-Config>
- <!-- 添加或修改安全分级对话框 -->
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px">
- <el-form-item label="信息名称" prop="infoName">
- <el-input v-model="form.infoName" maxlength="10" placeholder="请输入名称" style="width:320px;"/>
- </el-form-item>
- <el-form-item label="信息类目" prop="infoClassifyId" class="form-item">
- <el-select placeholder="请选择类目" v-model="form.infoClassifyId" style="width:320px;" @change="categoryClick()">
- <el-option
- v-for="dict in categoryList"
- :key="dict.id"
- :label="dict.classifyName"
- :value="dict.id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="信息类型">
- <el-input v-model="form.infoTypeName" placeholder="" disabled style="width:320px;"/>
- </el-form-item>
- <el-form-item label="信息内容" prop="infoContent" v-if="form.infoType==1">
- <el-input type="textarea" v-model="form.infoContent" placeholder="请输入内容" style="width:320px;"/>
- </el-form-item>
- <el-form-item label="信息内容" prop="infoContent" v-if="form.infoType==2">
- <el-upload
- class="certificate-avatar-uploader"
- :action="uploadImgUrl"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :headers="headers"
- :before-upload="beforeAvatarUpload">
- <div style="display: flex;">
- <img v-if="form.infoContent" :src="form.infoContent" style="width: 80px;height: 80px;margin-right: 10px">
- <i v-if="!form.infoContent" class="el-icon-plus avatar-uploader-icon"></i>
- </div>
- </el-upload>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getToken } from "@/utils/auth";
- import {
- infoCategoryList,
- infoConfigAdd, infoConfigList, infoConfigPut,infoConfigDelete
- } from '@/api/laboratory/safetyInfo'
- import safetyInfoConfig from "./safetyInfoConfig.vue"
- import { listHazard } from '@/api/permissionRequired'
- export default {
- name: "Approval",
- components: {
- safetyInfoConfig
- },
- data() {
- return {
- uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
- activeName: '',
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- //页面状态
- pageType:1,
- loading:false,
- headers: {
- Authorization: "Bearer " + getToken()
- },
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize:20,
- infoClassifyId:'',
- },
- total:0,
- tableData:[{}],
- dateRange:[],
- pageData2:{},
- tabsList:[],
- categoryList:[],
- // 表单参数
- form: {
- infoName:'',
- infoClassifyId:'',
- infoType:'',
- infoTypeName:'',
- infoContent:'',
- isCollective:'',
- },
- // 表单校验
- rules: {
- infoName: [
- { required: true, message: "请输入名称", trigger: "blur" },
- ],
- infoClassifyId: [
- { required: true, message: "请选择类目", trigger: "blur" },
- ],
- infoContent: [
- { required: true, message: "请添加信息内容", trigger: "blur" },
- ],
- }
- };
- },
- methods: {
- handleTabClick(tab){
- this.queryParams.infoClassifyId=tab.name;
- this.getList()
- },
- handleClick(index,row,doType){
- let self=this;
- if(doType=='add'){//添加
- delete this.form.id
- this.form.infoName='';
- this.form.infoClassifyId='';
- this.form.infoType='';
- this.form.infoTypeName='';
- this.form.infoContent='';
- this.open = true;
- }else if(doType=='edit'){//编辑
- this.form.id=row.id
- this.form.infoName=row.infoName
- this.form.infoClassifyId=row.infoClassifyId
- this.form.infoContent=row.infoContent
- this.form.infoType=row.infoType
- this.form.infoTypeName=row.infoType==1?'文字':'图片';
- this.open = true;
- }else if(doType=='deploy'){//信息牌配置
- self.pageType=2;
- }else if(doType=='delete'){//删除
- this.$confirm('确认要删除吗?', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- // 确定
- infoConfigDelete(row.id).then(response => {
- self.msgSuccess(response.msg);
- self.getList();
- });
- }).catch(function() {});
- }else if(doType=='back'){//返回
- self.pageType=1;
- }
- },
- categoryShow(row){
- let obj={
- id:row.id,
- isCollective:row.isCollective==1?2:1,
- }
- infoConfigPut(obj).then( response => {
- this.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- },
- categoryClick(){
- let _this=this;
- this.form.infoContent='';
- this.categoryList.forEach(function(item) {
- if(item.id==_this.form.infoClassifyId){
- _this.form.infoTypeName=item.classifyType==1?'文字':'图片';
- _this.form.infoType=item.classifyType;
- }
- })
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.handleQuery();
- },
- /** 取消按钮 */
- cancel() {
- this.open = false;
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate(valid => {
- if (valid) {
- if (this.form.id != null) {
- infoConfigPut(this.form).then( response => {
- this.msgSuccess("修改成功");
- this.open = false;
- this.getList();
- });
- } else {
- infoConfigAdd(this.form).then( response => {
- this.msgSuccess("新增成功");
- this.open = false;
- this.getList();
- });
- }
- }
- });
- },
- //上传
- handleAvatarSuccess(res, file) {
- this.form.infoContent = res.data.url;
- this.$forceUpdate()
- },
- beforeAvatarUpload(file) {
- let type = false;
- if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
- type = true;
- }else{
- this.$message.error('只能上传png/jpeg/gif格式图片');
- type = false;
- }
- return type;
- },
- //获取危险源列表
- getCategory(){
- listHazard({}).then(response=>{
- this.$set(this,'categoryList',response.data);
- })
- },
- //查询信息类目列表
- getCategoryList(){
- let _this=this;
- let obj={
- pageNum: 1,
- pageSize:100,
- isShow:1,
- remark:'sort',
- }
- infoCategoryList(obj).then( response => {
- let res=response.rows;
- if(response.code==200){
- if(res){
- _this.tabsList=res;
- _this.categoryList=res;
- _this.activeName=response.rows[0].id+''
- _this.queryParams.infoClassifyId=response.rows[0].id;
- this.getList()
- }
- }
- });
- },
- getList(){
- let _this=this;
- infoConfigList(_this.queryParams).then( response => {
- let res=response.rows;
- _this.tableData=res;
- _this.total=response.total;
- });
- },
- },
- mounted() {
- this.getCategoryList()
- }
- };
- </script>
- <style scoped lang="scss">
- .approval_handle {
- display: flex!important;
- flex-direction: column;
- flex-direction: column;
- box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
- border-radius:10px;
- padding-top: 20px !important;
- .approval_handle-page{
- padding:20px 20px 20px!important;
- flex:1;
- display: flex!important;
- flex-direction: column;
- .button-box{
- width:200px;
- display: flex;
- }
- }
- }
- </style>
- <style lang="scss">
- .tab-title{
- display: flex;
- justify-content: space-between;
- padding-bottom: 20px;
- box-sizing: border-box;
- border-bottom: 1px solid #E0E0E0;
- padding: 0 20px;
- .tab-title-l{
- flex: 1;
- .el-tabs__nav-wrap::after{
- background-color: #fff !important;
- }
- }
- }
- .category-switch .el-switch__label {
- position: absolute;
- display: none;
- color: #fff !important;
- }
- .category-switch .el-switch__label--right span {
- margin-left: 10px;
- }
- .category-switch .el-switch__label--left {
- z-index: 1;
- }
- .category-switch .el-switch__label--left span {
- margin-left: 24px;
- }
- .category-switch .el-switch__label.is-active {
- display: block;
- }
- .category-switch.el-switch .el-switch__core,
- .el-switch .el-switch__label {
- width: 60px !important;
- margin: 0;
- }
- </style>
|