safetyInfoCategory.vue 10.0 KB

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