safetyInfoCategory.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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="name">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="类目名称"
  10. clearable
  11. maxLength="30"
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item label="添加时间" prop="dateRange">
  16. <el-date-picker
  17. :clearable="false"
  18. v-model="dateRange"
  19. size="small"
  20. style="width: 240px"
  21. value-format="yyyy-MM-dd"
  22. type="daterange"
  23. range-separator="-"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. ></el-date-picker>
  27. </el-form-item>
  28. <el-form-item>
  29. <p class="inquire-button-one" @click="handleQuery">查询</p>
  30. <p class="reset-button-one" @click="resetQuery">重置</p>
  31. </el-form-item>
  32. <el-form-item style="float: right;">
  33. <el-col :span="1.5">
  34. <p class="inquire-button-one"
  35. v-hasPermi="['laboratory:classify:edit']"
  36. style="width:120px;margin-right:10px;"
  37. @click="handleClick('','','deploy')"
  38. >信息牌配置</p>
  39. <el-button
  40. v-hasPermi="['laboratory:classify:add']"
  41. type="primary"
  42. plain
  43. icon="el-icon-plus"
  44. size="mini"
  45. @click="handleClick('','','add')"
  46. >新增</el-button>
  47. </el-col>
  48. </el-form-item>
  49. </el-form>
  50. <el-table border v-loading="loading" :data="tableData">
  51. <el-table-column label="类目名称" align="left" prop="classifyName"/>
  52. <el-table-column label="内容类型" align="left" prop="classifyType">
  53. <template slot-scope="scope">
  54. <span v-if="scope.row.classifyType==1">文字</span>
  55. <span v-if="scope.row.classifyType==2">图片</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="颜色" align="left" prop="showColour" >
  59. <template slot-scope="scope">
  60. <p :style="'width:40px;height:23px;margin:0;background:'+scope.row.showColour"></p>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="创建人" align="left" prop="createBy"/>
  64. <el-table-column label="创建时间" align="left" prop="createTime"/>
  65. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="120">
  66. <template slot-scope="scope">
  67. <div class="button-box">
  68. <p class="table-min-button"
  69. v-hasPermi="['laboratory:classify:edit']"
  70. @click="handleClick('',scope.row,'edit')"
  71. >编辑</p>
  72. <p class="table-min-button"
  73. v-hasPermi="['laboratory:classify:remove']"
  74. @click="handleClick('',scope.row,'delete')"
  75. >删除</p>
  76. </div>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. <pagination :page-sizes="[20, 30, 40, 50]"
  81. :total="total"
  82. layout="total, prev, pager, next, sizes, jumper"
  83. :page.sync="queryParams.pageNum"
  84. :limit.sync="queryParams.pageSize"
  85. @pagination="getList"
  86. />
  87. </div>
  88. <info-Config v-if="pageType == 2"></info-Config>
  89. <!-- 添加或修改安全分级对话框 -->
  90. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :before-close="closeDialog">
  91. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  92. <el-form-item label="类目名称" prop="classifyName">
  93. <el-input v-model="form.classifyName" maxlength="10" placeholder="请输入类目名称" />
  94. </el-form-item>
  95. <el-form-item label="内容类型" prop="classifyType">
  96. <el-radio-group v-model="form.classifyType">
  97. <el-radio :label="1">文字</el-radio>
  98. <el-radio :label="2">图片</el-radio>
  99. </el-radio-group>
  100. </el-form-item>
  101. <el-form-item label="特殊类目" prop="isSpecial">
  102. <el-radio-group v-model="form.isSpecial">
  103. <el-radio :label="1">否</el-radio>
  104. <el-radio :label="2">是</el-radio>
  105. </el-radio-group>
  106. </el-form-item>
  107. <el-form-item label="类目颜色" prop="showColour">
  108. <el-color-picker v-model="form.showColour"></el-color-picker>
  109. </el-form-item>
  110. </el-form>
  111. <div slot="footer" class="dialog-footer">
  112. <el-button type="primary" @click="submitForm">确 定</el-button>
  113. <el-button @click="cancel">取 消</el-button>
  114. </div>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script>
  119. import { getToken } from "@/utils/auth";
  120. import { infoCategoryAdd, infoCategoryDelete, infoCategoryList, infoCategoryPut } from '@/api/laboratory/safetyInfo'
  121. import infoConfig from "./infoConfig.vue"
  122. export default {
  123. name: "Approval",
  124. components: {
  125. infoConfig
  126. },
  127. data() {
  128. return {
  129. // 弹出层标题
  130. title: "",
  131. // 是否显示弹出层
  132. open: false,
  133. //页面状态
  134. pageType:1,
  135. loading:false,
  136. headers: {
  137. Authorization: "Bearer " + getToken()
  138. },
  139. // 查询参数
  140. queryParams: {
  141. pageNum: 1,
  142. pageSize:20,
  143. searchValue:null,
  144. beginTime:null,
  145. endTime:null,
  146. remark:'time',
  147. },
  148. total:0,
  149. tableData:[],
  150. dateRange:[],
  151. pageData2:{},
  152. // 表单参数
  153. form: {
  154. classifyName:'',
  155. classifyType:'',
  156. isSpecial:'',
  157. showColour:'',
  158. },
  159. // 表单校验
  160. rules: {
  161. classifyName: [
  162. { required: true, message: "请输入类目名称", trigger: "blur" },
  163. ],
  164. classifyType: [
  165. { required: true, message: "请选择内容类型", trigger: "blur" },
  166. ],
  167. isSpecial: [
  168. { required: true, message: "请选择是否是特殊类目", trigger: "blur" },
  169. ],
  170. showColour: [
  171. { required: true, message: "请选择颜色", trigger: "blur" }
  172. ],
  173. }
  174. };
  175. },
  176. methods: {
  177. closeDialog(){
  178. this.$refs['form'].clearValidate()
  179. this.open=false
  180. },
  181. handleClick(index,row,doType){
  182. let _this=this;
  183. if(doType=='add'){//添加
  184. this.title='新增安全信息类目';
  185. this.open = true;
  186. delete this.form.id
  187. this.form.classifyName='';
  188. this.form.classifyType='';
  189. this.form.isSpecial='';
  190. this.form.showColour='';
  191. }else if(doType=='edit'){//编辑
  192. this.title='编辑安全信息类目';
  193. this.form.id=row.id
  194. this.form.classifyName=row.classifyName
  195. this.form.classifyType=row.classifyType
  196. this.form.isSpecial=row.isSpecial
  197. this.form.showColour=row.showColour
  198. this.open = true;
  199. }else if(doType=='deploy'){//信息牌配置
  200. _this.pageType=2;
  201. }else if(doType=='delete'){//删除
  202. // this.msgError('请删除安全信息后再删除信息类目')
  203. this.$confirm('确认要删除吗?', "警告", {
  204. confirmButtonText: "确定",
  205. cancelButtonText: "取消",
  206. type: "warning"
  207. }).then(() => {
  208. // 确定
  209. infoCategoryDelete(row.id).then(response => {
  210. _this.msgSuccess(response.msg);
  211. _this.getList();
  212. });
  213. }).catch(function() {});
  214. }else if(doType=='back'){//返回
  215. _this.pageType=1;
  216. }
  217. },
  218. /** 搜索按钮操作 */
  219. handleQuery() {
  220. this.queryParams.pageNum = 1;
  221. this.getList();
  222. },
  223. /** 重置按钮操作 */
  224. resetQuery() {
  225. this.queryParams.searchValue = null;
  226. this.dateRange=[];
  227. this.queryParams.beginTime=null;
  228. this.queryParams.endTime=null
  229. this.handleQuery();
  230. },
  231. /** 取消按钮 */
  232. cancel() {
  233. this.$refs['form'].clearValidate()
  234. this.open=false
  235. },
  236. /** 提交按钮 */
  237. submitForm() {
  238. this.$refs["form"].validate(valid => {
  239. if (valid) {
  240. if (this.form.id != null) {
  241. infoCategoryPut(this.form).then( response => {
  242. this.msgSuccess("修改成功");
  243. this.open = false;
  244. this.getList();
  245. });
  246. } else {
  247. infoCategoryAdd(this.form).then( response => {
  248. this.msgSuccess("新增成功");
  249. this.open = false;
  250. this.getList();
  251. });
  252. }
  253. }
  254. });
  255. },
  256. getList(){
  257. let _this=this;
  258. if(this.dateRange&&this.dateRange.length>0) {
  259. this.queryParams.beginTime=this.dateRange[0]
  260. this.queryParams.endTime=this.dateRange[1]
  261. } else {
  262. this.queryParams.beginTime=null;
  263. this.queryParams.endTime=null
  264. }
  265. infoCategoryList(_this.queryParams).then( response => {
  266. let res=response.rows;
  267. _this.tableData=res;
  268. _this.total=response.total;
  269. });
  270. },
  271. },
  272. mounted() {
  273. this.getList()
  274. }
  275. };
  276. </script>
  277. <style scoped lang="scss">
  278. .approval_handle {
  279. display: flex!important;
  280. flex-direction: column;
  281. .approval_handle-page{
  282. flex:1;
  283. display: flex!important;
  284. flex-direction: column;
  285. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  286. padding:20px 20px 20px!important;
  287. border-radius:10px;
  288. .button-box{
  289. width:200px;
  290. display: flex;
  291. }
  292. }
  293. }
  294. </style>