safetyInfoCategory.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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:'',
  140. startTime:'',
  141. endTime:'',
  142. },
  143. total:0,
  144. tableData:[{}],
  145. dateRange:[],
  146. pageData2:{},
  147. // 表单参数
  148. form: {
  149. classifyName:'',
  150. classifyType:'',
  151. isSpecial:'',
  152. showColour:'',
  153. },
  154. // 表单校验
  155. rules: {
  156. classifyName: [
  157. { required: true, message: "请输入类目名称", trigger: "blur" },
  158. ],
  159. classifyType: [
  160. { required: true, message: "请选择内容类型", trigger: "blur" },
  161. ],
  162. isSpecial: [
  163. { required: true, message: "请选择是否是特殊类目", trigger: "blur" },
  164. ],
  165. showColour: [
  166. { required: true, message: "请选择颜色", trigger: "blur" }
  167. ],
  168. }
  169. };
  170. },
  171. methods: {
  172. handleClick(index,row,doType){
  173. let _this=this;
  174. if(doType=='add'){//添加
  175. this.open = true;
  176. delete this.form.id
  177. this.form.classifyName='';
  178. this.form.classifyType='';
  179. this.form.isSpecial='';
  180. this.form.showColour='';
  181. }else if(doType=='edit'){//编辑
  182. this.form.id=row.id
  183. this.form.classifyName=row.classifyName
  184. this.form.classifyType=row.classifyType
  185. this.form.isSpecial=row.isSpecial
  186. this.form.showColour=row.showColour
  187. this.open = true;
  188. }else if(doType=='deploy'){//信息牌配置
  189. _this.pageType=2;
  190. }else if(doType=='delete'){//删除
  191. // this.msgError('请删除安全信息后再删除信息类目')
  192. this.$confirm('确认要删除吗?', "警告", {
  193. confirmButtonText: "确定",
  194. cancelButtonText: "取消",
  195. type: "warning"
  196. }).then(() => {
  197. // 确定
  198. infoCategoryDelete(row.id).then(response => {
  199. _this.msgSuccess(response.msg);
  200. _this.getList();
  201. });
  202. }).catch(function() {});
  203. }else if(doType=='back'){//返回
  204. _this.pageType=1;
  205. }
  206. },
  207. /** 搜索按钮操作 */
  208. handleQuery() {
  209. this.queryParams.pageNum = 1;
  210. this.getList();
  211. },
  212. /** 重置按钮操作 */
  213. resetQuery() {
  214. this.queryParams.searchValue = "";
  215. this.dateRange=[];
  216. this.queryParams.startTime=null;
  217. this.queryParams.endTime=null
  218. this.handleQuery();
  219. },
  220. /** 取消按钮 */
  221. cancel() {
  222. this.open = false;
  223. },
  224. /** 提交按钮 */
  225. submitForm() {
  226. this.$refs["form"].validate(valid => {
  227. if (valid) {
  228. if (this.form.id != null) {
  229. infoCategoryPut(this.form).then( response => {
  230. this.msgSuccess("修改成功");
  231. this.open = false;
  232. this.getList();
  233. });
  234. } else {
  235. infoCategoryAdd(this.form).then( response => {
  236. this.msgSuccess("新增成功");
  237. this.open = false;
  238. this.getList();
  239. });
  240. }
  241. }
  242. });
  243. },
  244. getList(){
  245. let _this=this;
  246. if(this.dateRange&&this.dateRange.length>0) {
  247. this.queryParams.startTime=this.dateRange[0]
  248. this.queryParams.endTime=this.dateRange[1]
  249. } else {
  250. this.queryParams.startTime=null;
  251. this.queryParams.endTime=null
  252. }
  253. infoCategoryList(_this.queryParams).then( response => {
  254. let res=response.rows;
  255. _this.tableData=res;
  256. _this.total=response.total;
  257. });
  258. },
  259. },
  260. mounted() {
  261. this.getList()
  262. }
  263. };
  264. </script>
  265. <style scoped lang="scss">
  266. .approval_handle {
  267. display: flex!important;
  268. flex-direction: column;
  269. .approval_handle-page{
  270. flex:1;
  271. display: flex!important;
  272. flex-direction: column;
  273. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  274. padding:20px 20px 20px!important;
  275. border-radius:10px;
  276. .button-box{
  277. width:200px;
  278. display: flex;
  279. }
  280. }
  281. }
  282. </style>