safetyInfoCategory.vue 9.3 KB

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