safetyInfoCategory.vue 11 KB

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