index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <!--化学品柜管理-->
  2. <template>
  3. <div class="app-container CabinetManagement">
  4. <div class="CabinetManagement-page" v-if="pageType == 1">
  5. <el-form :model="queryParamsData" ref="queryForm" :inline="true">
  6. <el-form-item label="关键字" prop="searchValue">
  7. <el-input
  8. maxlength="20"
  9. v-model="queryParamsData.searchValue"
  10. placeholder="化学品柜/编号"
  11. clearable
  12. size="small"
  13. />
  14. </el-form-item>
  15. <el-form-item label="学院" prop="deptId">
  16. <el-select v-model="queryParamsData.deptId" clearable placeholder="请选择学院">
  17. <el-option
  18. v-for="item in optionsListOne"
  19. :key="item.deptId"
  20. :label="item.deptName"
  21. :value="item.deptId">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="状态" prop="cabinetStatus">
  26. <el-select v-model="queryParamsData.cabinetStatus" clearable placeholder="请选择状态">
  27. <el-option
  28. v-for="item in optionsListTwo"
  29. :key="item.id"
  30. :label="item.name"
  31. :value="item.id">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item style="float: right;">
  36. <el-col :span="1.5">
  37. <p class="add-button-one-90"
  38. @click="pageToggle(2)"
  39. v-hasPermi="['chemical:hxpCabinet:add']"
  40. >新增</p>
  41. </el-col>
  42. </el-form-item>
  43. <el-form-item>
  44. <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
  45. <p class="reset-button-one" @click="resetQuery">重置</p>
  46. </el-form-item>
  47. </el-form>
  48. <el-table v-loading="loading" border :data="tableList">
  49. <el-table-column label="化学品柜编号" align="center" prop="cabinetNum" show-overflow-tooltip/>
  50. <el-table-column label="化学品柜" align="center" prop="cabinetName" show-overflow-tooltip/>
  51. <el-table-column label="学院" align="center" prop="deptName" show-overflow-tooltip/>
  52. <el-table-column label="化学品柜位置" align="center" prop="posi" show-overflow-tooltip/>
  53. <el-table-column label="状态" align="center" prop="cabinetStatus" width="120" v-hasPermi="['chemical:hxpCabinet:edit']">
  54. <template slot-scope="scope">
  55. <el-switch
  56. @click.native="changeIsNeedCaptcha(scope.row)"
  57. class="switch captcha-img"
  58. :active-value="1"
  59. :inactive-value="0"
  60. active-color="#0183FA"
  61. inactive-color="#999"
  62. v-model="scope.row.cabinetStatus"
  63. active-text="启用"
  64. inactive-text="停用"
  65. disabled
  66. ></el-switch>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="创建时间" align="center" prop="createTime" />
  70. <el-table-column label="创建人" align="center" prop="createBy" />
  71. <el-table-column label="负责人" align="center" prop="safeUserName" show-overflow-tooltip/>
  72. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240" v-if="tableButtonType">
  73. <template slot-scope="scope">
  74. <div class="table-button-box">
  75. <p class="table-button-null"></p>
  76. <p class="table-button-p" v-show="scope.row.cabinetLockList[0]&&$store.state.settings.smartAlarmType == 1" v-hasPermi="['chemical:locklog2:list']" @click="pageToggle(4,scope.row)">智能锁</p>
  77. <p class="table-button-p" v-hasPermi="['chemical:hxpCabinet:joinList']" @click="pageToggle(3,scope.row)">化学品</p>
  78. <el-dropdown @command="moreClick" v-hasPermi="['chemical:hxpCabinet:query','chemical:hxpCabinet:edit','chemical:hxpCabinet:remove']">
  79. <p class="table-button-p">更多>></p>
  80. <el-dropdown-menu slot="dropdown">
  81. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:1}" v-hasPermiAnd="['chemical:hxpCabinet:query','chemical:hxpCabinet:edit']">编辑</el-dropdown-item>
  82. <el-dropdown-item style="border-bottom:1px solid #E0E0E0;margin:0 10px;" :command="{row:scope.row,command:2}" v-hasPermi="['chemical:hxpCabinet:remove']">删除</el-dropdown-item>
  83. <el-dropdown-item style="margin:0 10px;" :command="{row:scope.row,command:3}">二维码</el-dropdown-item>
  84. </el-dropdown-menu>
  85. </el-dropdown>
  86. <p class="table-button-null"></p>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <pagination :page-sizes="[20, 30, 40, 50]"
  92. v-show="total>0"
  93. :total="total"
  94. :page.sync="queryParams.pageNum"
  95. :limit.sync="queryParams.pageSize"
  96. @pagination="getList"
  97. />
  98. </div>
  99. <!--新增/编辑-->
  100. <add-page v-if="pageType == 2" :addPropsData="addPropsData"></add-page>
  101. <!--化学品详情-->
  102. <list-page v-if="pageType == 3" :listPropsData="listPropsData"></list-page>
  103. <!--智能锁-->
  104. <smart-lock v-if="pageType == 4" :smartLockPropsData="smartLockPropsData"></smart-lock>
  105. <qr-code-dialog v-if="qrCodeDialogType" :qrCodeDialogData="qrCodeDialogData"></qr-code-dialog>
  106. </div>
  107. </template>
  108. <script>
  109. import { hxpCabinetList,getHxpCabinetInfo,putHxpCabinet,delHxpCabinet } from "@/api/medicUniversity-3_1/index";
  110. import { listDepartments } from "@/api/system/dept";
  111. import addPage from "./addPage.vue"
  112. import listPage from "./listPage.vue"
  113. import smartLock from "./smartLock.vue"
  114. import qrCodeDialog from "@/components/qrCodeDialog/index.vue"
  115. export default {
  116. name: "CabinetManagement",
  117. components: {
  118. addPage,
  119. listPage,
  120. smartLock,
  121. qrCodeDialog
  122. },
  123. data() {
  124. return {
  125. // table操作按钮校验
  126. tableButtonType:this.hasPermiDom(['chemical:hxpCabinet:joinList','chemical:hxpCabinet:query','chemical:hxpCabinet:edit','chemical:hxpCabinet:remove']),
  127. pageType:1,
  128. loading:false,
  129. //学院列表
  130. optionsListOne:[],
  131. //状态列表
  132. optionsListTwo:[
  133. {id:"1",name:"启用"},{id:"0",name:"停用"},
  134. ],
  135. // 搜索数据
  136. queryParamsData:{
  137. pageNum:1,
  138. pageSize:20,
  139. },
  140. // 搜索实际发送数据
  141. queryParams:{
  142. pageNum:1,
  143. pageSize:20,
  144. },
  145. //数据数量
  146. total:0,
  147. tableList:[],
  148. //编辑页面传参
  149. addPropsData:{},
  150. //化学品页面传参
  151. listPropsData:{},
  152. //智能锁页面传参
  153. smartLockPropsData:{},
  154. //二维码组件参数
  155. qrCodeDialogType:false,
  156. qrCodeDialogData:{},
  157. };
  158. },
  159. created() {
  160. },
  161. mounted(){
  162. this.listDepartments();
  163. this.getList();
  164. },
  165. methods: {
  166. //更多选项
  167. moreClick(data){
  168. let self = this;
  169. if(data.command == 1){
  170. //编辑
  171. getHxpCabinetInfo(data.row.id).then(response => {
  172. this.addPropsData = response.data;
  173. this.pageType = 2;
  174. });
  175. }else if(data.command == 2){
  176. if(data.row.cabinetLockList[0]){
  177. this.msgError('已关联柜锁,无法删除')
  178. return
  179. }
  180. // this.msgError('该化学试剂有存放库存,无法删除,请先操作出库.');
  181. this.$confirm('确认要删除吗?', "警告", {
  182. confirmButtonText: "确定",
  183. cancelButtonText: "取消",
  184. type: "warning"
  185. }).then(function() {
  186. delHxpCabinet(data.row.id).then(response => {
  187. self.msgSuccess(response.msg);
  188. self.pageToggle(1,'get');
  189. });
  190. }).then(() => {
  191. }).catch(() => {});
  192. }else if(data.command == 3){
  193. console.log('二维码')
  194. this.qrCodeDialogButton(1,data.row.id,data.row.cabinetName)
  195. }
  196. },
  197. //二维码组件开关
  198. qrCodeDialogButton(type,id,name){
  199. if(type == 1){
  200. this.$set(this,'qrCodeDialogData',{
  201. type:'chemicalsCabinet', //二维码类型 用于区分二维码功能类型
  202. parameter:id, //二维码参数
  203. name:name, //二维码名称用于下载时命名
  204. });
  205. this.$set(this,'qrCodeDialogType',true);
  206. }else{
  207. this.$set(this,'qrCodeDialogType',false);
  208. }
  209. },
  210. //启用/停用
  211. changeIsNeedCaptcha(item){
  212. let obj = {
  213. id:item.id,
  214. }
  215. if(item.cabinetStatus == 1){
  216. obj.cabinetStatus = 0;
  217. }else{
  218. obj.cabinetStatus = 1;
  219. }
  220. putHxpCabinet(obj).then(response => {
  221. this.msgSuccess(response.msg)
  222. this.pageToggle(1,'get');
  223. });
  224. },
  225. //获取学院列表
  226. listDepartments(){
  227. listDepartments().then(response => {
  228. this.optionsListOne = response.data;
  229. });
  230. },
  231. pageToggle(type,item){
  232. if(type == 1){
  233. this.pageType = 1;
  234. if(item == 'refresh'){
  235. this.resetQuery();
  236. }else if(item == 'get'){
  237. this.getList();
  238. }
  239. }else if(type == 2){
  240. //新增
  241. this.addPropsData = {};
  242. this.pageType = 2;
  243. }else if(type == 3){
  244. //化学品详情
  245. this.listPropsData = item;
  246. this.pageType = 3;
  247. }else if(type == 4){
  248. //智能锁
  249. this.smartLockPropsData = item;
  250. this.pageType = 4;
  251. }
  252. },
  253. //获取数据列表
  254. getList(){
  255. this.queryParamsData = JSON.parse(JSON.stringify(this.queryParams));
  256. hxpCabinetList(this.queryParamsData).then(response => {
  257. this.tableList = response.rows;
  258. this.total = response.total
  259. });
  260. },
  261. /** 搜索按钮操作 */
  262. handleQuery() {
  263. this.queryParamsData.pageNum = 1;
  264. this.queryParamsData.pageSize = 20;
  265. this.queryParams = JSON.parse(JSON.stringify(this.queryParamsData));
  266. this.getList();
  267. },
  268. /** 重置按钮操作 */
  269. resetQuery() {
  270. this.$set(this,'queryParamsData',{});
  271. this.$set(this,'queryParams',{});
  272. this.handleQuery();
  273. },
  274. }
  275. }
  276. </script>
  277. <style scoped lang="scss">
  278. .CabinetManagement{
  279. flex:1;
  280. display: flex;
  281. flex-direction: column;
  282. overflow: hidden!important;
  283. p{
  284. margin:0;
  285. padding:0;
  286. }
  287. .CabinetManagement-page{
  288. flex:1;
  289. display: flex;
  290. flex-direction: column;
  291. overflow: hidden;
  292. padding:20px;
  293. .button-box{
  294. display: flex;
  295. }
  296. }
  297. }
  298. </style>
  299. <style lang="scss">
  300. .CabinetManagement-page{
  301. .switch .el-switch__label {
  302. position: absolute;
  303. display: none;
  304. color: #fff !important;
  305. }
  306. .switch .el-switch__label--right {
  307. z-index: 1;
  308. }
  309. .switch .el-switch__label--right span{
  310. margin-left:10px;
  311. }
  312. .switch .el-switch__label--left {
  313. z-index: 1;
  314. }
  315. .switch .el-switch__label--left span{
  316. margin-left: 24px;
  317. }
  318. .switch .el-switch__label.is-active {
  319. display: block;
  320. }
  321. .switch.el-switch .el-switch__core,
  322. .el-switch .el-switch__label {
  323. width: 64px !important;
  324. margin: 0;
  325. }
  326. }
  327. </style>