addPage.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. <!--新增/编辑化学品柜-->
  2. <template>
  3. <div class="page-container chemicalsCabinetManage-addPage">
  4. <div class="page-top-title-box">
  5. <p class="page-top-title-name-p">{{newData.cabinetId?'编辑化学品柜':'新增化学品柜'}}</p>
  6. <p class="page-top-title-out-p" @click="backPage">返回</p>
  7. <p class="page-top-title-submit-p" @click="submitForm">提交</p>
  8. </div>
  9. <div class="content-box scrollbar-box">
  10. <el-form class="add-form-box" :model="newData" ref="form" :rules="rules" label-width="140px">
  11. <div class="form-max-box">
  12. <el-form-item label="名称:" prop="cabinetName">
  13. <el-input v-model="newData.cabinetName" placeholder="请输入化学品柜名称" maxLength="20" style="width:500px;"></el-input>
  14. </el-form-item>
  15. <el-form-item label="学院:" prop="deptId">
  16. <el-select v-model="newData.deptId" @change="deptChange" placeholder="请选择所属学院" style="width: 500px">
  17. <el-option
  18. v-for="item in deptOptions"
  19. :key="item.deptId"
  20. :label="item.deptName"
  21. :value="item.deptId"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. </div>
  26. <div class="form-max-box">
  27. <el-form-item label="实验室:" prop="subId">
  28. <el-select v-model="newData.subId" @change="subChange" placeholder="请选择实验室" style="width: 500px">
  29. <el-option
  30. v-for="item in subOptions"
  31. :key="item.subId"
  32. :label="item.subName"
  33. :value="item.subId"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <!--<el-form-item label="摄像头:" prop="cameraId">-->
  38. <!--<el-select v-model="newData.cameraId" placeholder="请选择摄像头" style="width: 500px">-->
  39. <!--<el-option-->
  40. <!--v-for="item in cameraOptions"-->
  41. <!--:key="item.value"-->
  42. <!--:label="item.label"-->
  43. <!--:value="item.value"-->
  44. <!--/>-->
  45. <!--</el-select>-->
  46. <!--</el-form-item>-->
  47. </div>
  48. <!--<div class="form-max-box">-->
  49. <!--<el-form-item label="采集器:" prop="collectorId">-->
  50. <!--<el-select v-model="newData.collectorId" placeholder="请选择采集器" style="width: 500px">-->
  51. <!--<el-option-->
  52. <!--v-for="item in harvesterOptions"-->
  53. <!--:key="item.value"-->
  54. <!--:label="item.label"-->
  55. <!--:value="item.value"-->
  56. <!--/>-->
  57. <!--</el-select>-->
  58. <!--</el-form-item>-->
  59. <!--</div>-->
  60. <div class="form-max-box">
  61. <el-form-item label="柜门设置:" prop="cabinetDoorModelList">
  62. <div class="form-add-box">
  63. <p class="add-time-button-p" @click="addItemButton">+ 新增柜门</p>
  64. <p>请按照从上到下的顺序进行添加</p>
  65. </div>
  66. </el-form-item>
  67. </div>
  68. <div class="form-big-box">
  69. <div class="form-for-max-box" v-for="(item,index) in newData.cabinetDoorModelList" :key="index">
  70. <p class="el-icon-circle-close del-position-p" @click="deleteItemButton(index,item)"></p>
  71. <div class="item-box">
  72. <el-form-item label="柜门名称:" label-width="100px"
  73. :prop="'cabinetDoorModelList.'+ index +'.doorName'" :rules="rules.itemData1">
  74. <el-input v-model="item.doorName" placeholder="请输入柜门名称"
  75. clearable maxLength="5" style="width:280px;"></el-input>
  76. </el-form-item>
  77. </div>
  78. <div class="item-text-box">
  79. <el-form-item label="层数:" label-width="100px"
  80. :prop="'cabinetDoorModelList.'+ index +'.doorLayers'" :rules="rules.itemData2">
  81. <el-input-number v-model="item.doorLayers" style="width:200px;"
  82. :controls="false" :min="1" :max="10">
  83. </el-input-number>
  84. </el-form-item>
  85. <p class="tips-p">层</p>
  86. </div>
  87. <div class="item-box">
  88. <el-form-item label="管理员:" label-width="100px"
  89. :prop="'cabinetDoorModelList.'+ index +'.cabinetAdminModelList'" :rules="rules.cabinetAdminModelList">
  90. <el-select
  91. style="width:460px;"
  92. v-model="item.cabinetAdminModelList"
  93. multiple
  94. filterable
  95. remote
  96. clearable
  97. reserve-keyword
  98. @change="(val)=>userSelectClick(val,index)"
  99. @clear="userClearClick"
  100. placeholder="请输入姓名进行搜索"
  101. :remote-method="(val)=>userSelect(val,index)">
  102. <el-option
  103. v-for="itemOptions in item.userOptions"
  104. :key="itemOptions.userId"
  105. :label="itemOptions.userName"
  106. :value="itemOptions.userId">
  107. </el-option>
  108. </el-select>
  109. </el-form-item>
  110. </div>
  111. <div class="item-box">
  112. <el-form-item label="开门方式:" label-width="100px"
  113. :prop="'cabinetDoorModelList.'+ index +'.unlockingMethod'" :rules="rules.unlockingMethod">
  114. <el-select v-model="item.unlockingMethod" placeholder="请选择开门方式" @change="unlockingMethodChange(index)" style="width: 460px">
  115. <el-option
  116. v-for="item in openOptions"
  117. :key="item.value"
  118. :label="item.label"
  119. :value="item.value"
  120. />
  121. </el-select>
  122. </el-form-item>
  123. </div>
  124. <div class="item-box" v-if="item.unlockingMethod == 2">
  125. <el-form-item label="智能锁:" label-width="100px"
  126. :prop="'cabinetDoorModelList.'+ index +'.cabinetLockList'" :rules="rules.cabinetLockList">
  127. <el-select v-model="item.cabinetLockList" multiple placeholder="请选择" @change="(val)=>lockChange(index,val)" :multiple-limit='2' style="width: 460px">
  128. <el-option
  129. v-for="item in lockOptions"
  130. :key="item.lockId"
  131. :label="item.lockName"
  132. :value="item.lockId"
  133. :disabled="item.disabled"
  134. >
  135. {{item.lockName}}-{{item.lockNum}}
  136. </el-option>
  137. </el-select>
  138. </el-form-item>
  139. </div>
  140. <div class="item-box" v-if="item.unlockingMethod == 3" style="display: flex;">
  141. <el-form-item label="钥匙柜:" label-width="100px"
  142. :prop="'cabinetDoorModelList.'+ index +'.cabinetLockList'" :rules="rules.cabinetLockList">
  143. <el-select v-model="item.cabinetLockList" multiple placeholder="请选择" @change="(val)=>cabinetLockChange(index,val)" :multiple-limit='1' style="width: 180px">
  144. <el-option
  145. v-for="item in keyCabinetOptions"
  146. :key="item.lockId"
  147. :label="item.lockName"
  148. :value="item.lockId"
  149. :disabled="item.disabled"
  150. >
  151. {{item.lockName}}-{{item.lockNum}}
  152. </el-option>
  153. </el-select>
  154. </el-form-item>
  155. <el-form-item label="柜格:" label-width="100px"
  156. :prop="'cabinetDoorModelList.'+ index +'.cabinetLattice'" :rules="rules.cabinetLattice">
  157. <el-select v-model="item.cabinetLattice" multiple placeholder="请选择" :multiple-limit='9' collapse-tags style="width: 180px">
  158. <el-option
  159. v-for="item in gratingOptions"
  160. :key="item.value"
  161. :label="item.label"
  162. :value="item.value">
  163. </el-option>
  164. </el-select>
  165. </el-form-item>
  166. </div>
  167. </div>
  168. </div>
  169. </el-form>
  170. </div>
  171. </div>
  172. </template>
  173. <script>
  174. import { getDeptDropList, systemUserSelect,iotDeviceFindByType } from '@/api/commonality/permission'
  175. import { laboratorySubRelInfoGetRelList } from '@/api/commonality/noPermission'
  176. import {
  177. chemicalCabinetAdd, chemicalCabinetGetLockList,
  178. chemicalCabinetUpdate,
  179. chemicalStockGetStockByDoorId
  180. } from '@/api/chemicalManage'
  181. export default {
  182. name: 'addPage',
  183. props:{
  184. propsData:{},
  185. },
  186. data(){
  187. return{
  188. deptOptions:[],
  189. subOptions:[],
  190. cameraOptions:[
  191. {label:'摄像头1',value:'1'},
  192. {label:'摄像头2',value:'2'},
  193. {label:'摄像头3',value:'3'},
  194. ],
  195. harvesterOptions:[
  196. {label:'采集器1',value:'1'},
  197. {label:'采集器2',value:'2'},
  198. {label:'采集器3',value:'3'},
  199. ],
  200. userOptions:[],
  201. userOptionsArr:[],//临时存储管理员数组
  202. openOptions:[
  203. {label:'无锁',value:'1'},
  204. {label:'智能锁',value:'2'},
  205. // {label:'钥匙柜',value:'3'},
  206. ],
  207. lockOptions:[],
  208. keyCabinetOptions:[
  209. {lockName:'钥匙柜名称1',lockId:'1',lockNum:'00001'},
  210. {lockName:'钥匙柜名称2',lockId:'2',lockNum:'00002'},
  211. {lockName:'钥匙柜名称3',lockId:'3',lockNum:'00003'},
  212. ],
  213. gratingOptions:[
  214. {label:'1号格',value:'1'},
  215. {label:'2号格',value:'2'},
  216. {label:'3号格',value:'3'},
  217. {label:'4号格',value:'4'},
  218. {label:'5号格',value:'5'},
  219. {label:'6号格',value:'6'},
  220. {label:'7号格',value:'7'},
  221. {label:'8号格',value:'8'},
  222. {label:'9号格',value:'9'},
  223. ],
  224. //当前实验室管理员和安全员id
  225. adminAndSafeId:[],
  226. //当前实验室管理员和安全员id和name
  227. adminAndSafeList:[],
  228. newData:{
  229. cabinetName:'',
  230. deptId:'',
  231. deptName:'',
  232. subId:'',
  233. subName:'',
  234. cameraId:'',
  235. collectorId:'',
  236. cabinetDoorModelList:[
  237. {
  238. doorName:'默认柜门1',
  239. doorLayers:'',
  240. cabinetAdminModelList:[],
  241. unlockingMethod:'1',
  242. cabinetLockList:[],
  243. cabinetLattice:[],
  244. userOptions:[],
  245. userNameOptions:[],
  246. }
  247. ],
  248. },
  249. rules:{
  250. cabinetName: [
  251. { required: true, message: "请输入化学品柜名称", trigger: "blur" },
  252. { required: true, message: "请输入化学品柜名称", validator: this.spaceJudgment, trigger: "blur" }
  253. ],
  254. deptId: [
  255. { required: true, message: "请选择学院", trigger: "blur" },
  256. { required: true, message: "请选择学院", validator: this.spaceJudgment, trigger: "blur" }
  257. ],
  258. subId: [
  259. { required: true, message: "请选择实验室", trigger: "blur" },
  260. { required: true, message: "请选择实验室", validator: this.spaceJudgment, trigger: "blur" }
  261. ],
  262. cameraId: [
  263. { required: true, message: "请选择摄像头", trigger: "blur" },
  264. { required: true, message: "请选择摄像头", validator: this.spaceJudgment, trigger: "blur" }
  265. ],
  266. collectorId: [
  267. { required: true, message: "请选择采集器", trigger: "blur" },
  268. { required: true, message: "请选择采集器", validator: this.spaceJudgment, trigger: "blur" }
  269. ],
  270. cabinetDoorModelList: [
  271. { required: true, message: "请添加柜门", trigger: "blur" },
  272. { required: true, message: "请添加柜门", validator: this.spaceJudgment, trigger: "blur" }
  273. ],
  274. doorName: [
  275. { required: true, message: "请输入柜门名称", trigger: "blur" },
  276. { required: true, message: "请输入柜门名称", validator: this.spaceJudgment, trigger: "blur" }
  277. ],
  278. doorLayers: [
  279. { required: true, message: "请输入层数", trigger: "blur" },
  280. { required: true, message: "请输入层数", validator: this.spaceJudgment, trigger: "blur" }
  281. ],
  282. cabinetAdminModelList: [
  283. { required: true, message: "请选择管理员", trigger: "blur" },
  284. { required: true, message: "请选择管理员", validator: this.spaceJudgment, trigger: "blur" }
  285. ],
  286. unlockingMethod: [
  287. { required: true, message: "请选择开门方式", trigger: "blur" },
  288. { required: true, message: "请选择开门方式", validator: this.spaceJudgment, trigger: "blur" }
  289. ],
  290. cabinetLockList: [
  291. { required: true, message: "请选择智能锁", trigger: "blur" },
  292. { required: true, message: "请选择智能锁", validator: this.spaceJudgment, trigger: "blur" }
  293. ],
  294. cabinetLattice: [
  295. { required: true, message: "请选择柜格", trigger: "blur" },
  296. { required: true, message: "请选择柜格", validator: this.spaceJudgment, trigger: "blur" }
  297. ],
  298. },
  299. //实验室管理员数据
  300. safeList:[],
  301. safeIdList:[],
  302. //过滤柜锁
  303. filterCabinetLock:[],
  304. //存储编辑的时候返回的智能锁
  305. editLockList:[],
  306. }
  307. },
  308. created(){
  309. },
  310. mounted(){
  311. let self=this;
  312. this.initialize();
  313. this.getDeptDropList();
  314. },
  315. methods:{
  316. //初始化
  317. initialize(){
  318. let self=this;
  319. if(this.propsData.cabinetId){
  320. let obj = JSON.parse(JSON.stringify(this.propsData))
  321. let newData = {
  322. cabinetId:obj.cabinetId,
  323. cabinetName:obj.cabinetName,
  324. deptId:obj.deptId,
  325. deptName:obj.deptName,
  326. subId:obj.subId,
  327. subName:obj.subName,
  328. cameraId:obj.cameraId,
  329. collectorId:obj.collectorId,
  330. cabinetDoorModelList:[],
  331. }
  332. obj.cabinetDoorVoList.forEach((item)=>{
  333. let minObj = {
  334. doorLayers:item.doorLayers,
  335. doorName:item.doorName,
  336. doorUniqueId:item.doorUniqueId,
  337. unlockingMethod:item.unlockingMethod+'',
  338. cabinetLockList:[],
  339. cabinetAdminModelList:[],
  340. userOptions:[],
  341. userNameOptions:[],
  342. };
  343. if(item.cabinetLockVoList){
  344. item.cabinetLockVoList.forEach((bigItem)=>{
  345. minObj.cabinetLockList.push(bigItem.lockId)
  346. this.editLockList.push(bigItem.lockId)
  347. })
  348. }
  349. if(item.cabinetAdminVoList){
  350. item.cabinetAdminVoList.forEach((minItem)=>{
  351. minObj.cabinetAdminModelList.push(minItem.userId)
  352. minObj.userOptions.push({
  353. userId:minItem.userId,
  354. userName:minItem.userName,
  355. })
  356. minObj.userNameOptions.push({
  357. userId:minItem.userId,
  358. userName:minItem.userName,
  359. })
  360. })
  361. }
  362. newData.cabinetDoorModelList.push(minObj);
  363. })
  364. this.subOptions=[{subId:obj.subId,subName:obj.subName,}]
  365. this.$set(this,'newData',newData);
  366. this.chemicalCabinetGetLockList(this.newData.cabinetId);
  367. }else{
  368. this.chemicalCabinetGetLockList('');
  369. }
  370. },
  371. // 返回按钮
  372. backPage(){
  373. this.$parent.tableButton(5);
  374. },
  375. //人员数组去重
  376. unique(arr) {
  377. for(var i=0; i<arr.length; i++){
  378. for(var j=i+1; j<arr.length; j++){
  379. if(arr[i].userId==arr[j].userId){ //第一个等同于第二个,splice方法删除第二个
  380. arr.splice(j,1);
  381. j--;
  382. }
  383. }
  384. }
  385. return arr;
  386. },
  387. /** 提交按钮 */
  388. submitForm() {
  389. let self = this;
  390. this.$refs["form"].validate(valid => {
  391. if (valid) {
  392. let obj = JSON.parse(JSON.stringify(this.newData))
  393. let modelList = [];
  394. obj.cabinetDoorModelList.forEach((item)=>{
  395. let userList = [];
  396. item.cabinetAdminModelList.forEach((bigItem)=>{
  397. let num = 0;
  398. item.userNameOptions.forEach((minItem)=>{
  399. if(bigItem == minItem.userId){
  400. if(num < 1){
  401. num++
  402. userList.push({
  403. userId:minItem.userId,
  404. userName:minItem.userName,
  405. })
  406. }
  407. }
  408. })
  409. })
  410. delete item.userOptions;
  411. delete item.userNameOptions;
  412. let lockList = [];
  413. item.cabinetLockList.forEach((item)=>{
  414. self.lockOptions.forEach((minItem)=>{
  415. if(item == minItem.lockId){
  416. lockList.push({
  417. lockId: minItem.lockId,
  418. lockName: minItem.lockName,
  419. lockNum: minItem.lockNum,
  420. })
  421. }
  422. })
  423. })
  424. modelList.push({
  425. doorLayers:item.doorLayers,
  426. doorUniqueId:item.doorUniqueId,
  427. doorName:item.doorName,
  428. unlockingMethod:item.unlockingMethod,
  429. cabinetLockList:lockList,
  430. cabinetAdminModelList:userList,
  431. })
  432. })
  433. let upData = {
  434. cabinetName : obj.cabinetName,
  435. deptId : obj.deptId,
  436. deptName : obj.deptName,
  437. subId : obj.subId,
  438. subName : obj.subName,
  439. cameraId:1,
  440. collectorId:1,
  441. cabinetDoorModelList:modelList,
  442. }
  443. if (this.newData.cabinetId){//编辑
  444. upData.cabinetId = this.newData.cabinetId;
  445. chemicalCabinetUpdate(upData).then( response => {
  446. self.msgSuccess("提交成功")
  447. self.$parent.tableButton(5);
  448. });
  449. }else{//提交
  450. chemicalCabinetAdd(upData).then( response => {
  451. self.msgSuccess("提交成功")
  452. self.$parent.tableButton(5);
  453. });
  454. }
  455. }
  456. })
  457. },
  458. //化学品柜-过滤柜锁
  459. chemicalCabinetGetLockList(cabinetId){
  460. chemicalCabinetGetLockList({cabinetId:cabinetId}).then(response => {
  461. this.$set(this, 'filterCabinetLock', response.data)
  462. if (this.newData.cabinetId){
  463. this.iotDeviceFindByType(this.newData.subId);
  464. }
  465. });
  466. },
  467. //查询学院列表
  468. getDeptDropList(){
  469. getDeptDropList({deptName:"",level:2,deptType:1}).then(response => {
  470. this.$set(this, 'deptOptions', response.data)
  471. });
  472. },
  473. //学院选中
  474. deptChange(){
  475. this.$set(this.newData,'subId','');
  476. this.$set(this,'userOptions',[]);
  477. this.newData.cabinetDoorModelList.forEach((item,index)=>{
  478. item.doorName = '默认柜门'+(index+1);
  479. item.doorLayers = '';
  480. item.unlockingMethod = '1';
  481. item.cabinetLockList = [];
  482. item.cabinetAdminModelList = [];
  483. item.userOptions = [];
  484. item.userNameOptions = [];
  485. })
  486. for (let i=0;i<this.deptOptions.length;i++){
  487. if (this.newData.deptId==this.deptOptions[i].deptId){
  488. this.$set(this.newData, 'deptName', this.deptOptions[i].deptName)
  489. }
  490. }
  491. this.laboratorySubRelInfoGetRelList(this.newData.deptId,'');
  492. },
  493. //根据学院id查询实验室列表
  494. laboratorySubRelInfoGetRelList(deptId,subId){
  495. let obj = {
  496. deptId:deptId,
  497. subId:subId,
  498. subName:'',
  499. }
  500. laboratorySubRelInfoGetRelList(obj).then(response => {
  501. this.subOptions = response.data;
  502. });
  503. },
  504. //实验室选中
  505. subChange(val){
  506. let list = [];
  507. let idList = [];
  508. this.subOptions.forEach((item)=>{
  509. if(item.subId == val){
  510. this.$set(this.newData, 'subName', item.subName)
  511. if (item.adminId){
  512. idList.push(item.adminId)
  513. list.push({
  514. userId:item.adminId,
  515. userName:item.adminName,
  516. })
  517. }
  518. if (item.oneSafeId){
  519. if(item.adminId != item.oneSafeId){
  520. idList.push(item.oneSafeId)
  521. list.push({
  522. userId:item.oneSafeId,
  523. userName:item.oneSafeName,
  524. })
  525. }else{
  526. if(item.twoSafeId){
  527. if(item.adminId != item.twoSafeId){
  528. idList.push(item.twoSafeId)
  529. list.push({
  530. userId:item.twoSafeId,
  531. userName:item.twoSafeName,
  532. })
  533. }
  534. }
  535. }
  536. }
  537. }
  538. })
  539. this.$set(this,'safeList',list);
  540. this.$set(this,'safeIdList',idList);
  541. //刷新现有数据
  542. this.newData.cabinetDoorModelList.forEach((item,index)=>{
  543. item.doorName = '默认柜门'+(index+1);
  544. item.doorLayers = '';
  545. item.unlockingMethod = '1';
  546. item.cabinetLockList = [];
  547. item.cabinetAdminModelList = idList;
  548. item.userOptions = JSON.parse(JSON.stringify(list));
  549. item.userNameOptions = JSON.parse(JSON.stringify(list));
  550. })
  551. this.iotDeviceFindByType(this.newData.subId);
  552. },
  553. //人员选中触发
  554. userSelectClick(val,index){
  555. let self = this;
  556. this.newData.cabinetDoorModelList[index].userOptions.forEach((item)=>{
  557. val.forEach((item2)=>{
  558. if(item.userId == item2){
  559. self.newData.cabinetDoorModelList[index].userNameOptions.push({
  560. userId:item.userId,
  561. userName:item.userName,
  562. })
  563. }
  564. })
  565. })
  566. this.$forceUpdate()
  567. },
  568. //人员清空触发
  569. userClearClick(){
  570. },
  571. //人员查询
  572. userSelect(query,index){
  573. if (query !== '') {
  574. let obj = {
  575. userType:'',
  576. userName:query,
  577. }
  578. systemUserSelect(obj).then(response => {
  579. this.$set(this.newData.cabinetDoorModelList[index],'userOptions',response.data);
  580. // this.userOptions = response.data;
  581. // self.userOptionsArr=[...self.userOptionsArr,...response.data]
  582. });
  583. } else {
  584. this.userOptions = [];
  585. }
  586. },
  587. //开门方式切换
  588. unlockingMethodChange(index){
  589. this.$set(this.newData.cabinetDoorModelList[index],'cabinetLockList',[]);
  590. this.$set(this.newData.cabinetDoorModelList[index],'cabinetLockListArr',[]);
  591. },
  592. //查询智能锁列表
  593. iotDeviceFindByType(subId){
  594. iotDeviceFindByType({subjectId:subId,typeKeyList:['cabinetLock'],ids:this.filterCabinetLock}).then(response => {
  595. let list=[];
  596. response.data.forEach(function(item) {
  597. list.push({lockName:item.deviceName,lockId:item.id,lockNum:item.deviceNo})
  598. })
  599. this.$set(this, 'lockOptions', list)
  600. if (this.newData.cabinetId){
  601. let editLockListArr = Array.from(new Set(this.editLockList));
  602. this.lockOptions.forEach(v => {
  603. v.disabled = false
  604. editLockListArr.forEach(item=>{
  605. if (item ==v.lockId){
  606. v.disabled = true
  607. }
  608. })
  609. })
  610. }
  611. });
  612. },
  613. //智能锁选中触发
  614. lockChange(index,val){
  615. let self = this;
  616. this.lockOptions.forEach(v => {
  617. v.disabled = false
  618. console.log(self.newData.cabinetDoorModelList[index])
  619. val.forEach(item=>{
  620. if (item ==v.lockId){
  621. v.disabled = true
  622. }
  623. })
  624. })
  625. },
  626. //钥匙柜选中触发
  627. cabinetLockChange(index,val){
  628. let self = this;
  629. let list=[];
  630. val.forEach((item)=>{
  631. self.keyCabinetOptions.forEach((minItem)=>{
  632. if(item == minItem.lockId){
  633. list.push({
  634. lockName:minItem.lockName,
  635. lockId:minItem.lockId,
  636. lockNum:minItem.lockNum
  637. })
  638. }
  639. })
  640. })
  641. this.$set(this.newData.cabinetDoorModelList[index],'cabinetLockListArr',list);
  642. },
  643. //添加柜门
  644. addItemButton(){
  645. if(this.newData.cabinetDoorModelList[5]){
  646. this.msgError('最多添加6个柜门')
  647. }else{
  648. this.newData.cabinetDoorModelList.push({
  649. doorName:'默认柜门'+Number(this.newData.cabinetDoorModelList.length+1),
  650. doorLayers:'',
  651. cabinetAdminModelList:this.safeIdList,
  652. unlockingMethod:'1',
  653. cabinetLockList:[],
  654. cabinetLattice:'',
  655. userOptions:this.safeList,
  656. userNameOptions:this.safeList,
  657. })
  658. this.$forceUpdate()
  659. }
  660. },
  661. //删除柜门
  662. deleteItemButton(index,item){
  663. console.log(item)
  664. let self=this;
  665. if(this.newData.cabinetDoorModelList.length ==1){
  666. this.msgError('最少添加1个柜门')
  667. }else{
  668. if (this.newData.cabinetId){//编辑
  669. chemicalStockGetStockByDoorId({doorUniqueId:item.doorUniqueId}).then(response => {
  670. if (response.data){
  671. self.newData.cabinetDoorModelList.splice(index,1);
  672. self.$forceUpdate()
  673. }else{
  674. self.msgError("该柜门不能删除!");
  675. }
  676. });
  677. }else{//新增
  678. self.newData.cabinetDoorModelList.splice(index,1);
  679. self.$forceUpdate()
  680. }
  681. }
  682. },
  683. },
  684. }
  685. </script>
  686. <style scoped lang="scss">
  687. .chemicalsCabinetManage-addPage{
  688. .content-box{
  689. flex:1;
  690. display: flex;
  691. padding:30px;
  692. .form-max-box{
  693. display: flex;
  694. .form-add-box{
  695. display: flex;
  696. .add-time-button-p{
  697. width:100px;
  698. height:40px;
  699. line-height:40px;
  700. text-align: center;
  701. cursor: pointer;
  702. background-color: #0183FA;
  703. border-radius:4px;
  704. color:#fff;
  705. margin-right: 35px;
  706. }
  707. p:nth-child(2){
  708. font-size:14px;
  709. color:#999999;
  710. }
  711. }
  712. }
  713. .form-big-box{
  714. padding-bottom:20px;
  715. .form-for-max-box{
  716. width:600px;
  717. margin-left:140px;
  718. border:1px solid #E0E0E0;
  719. border-radius:4px;
  720. padding-top:20px;
  721. position: relative;
  722. margin-bottom:20px;
  723. .item-text-box{
  724. display: flex;
  725. ::v-deep input{
  726. border-top-right-radius: 0;
  727. border-bottom-right-radius: 0;
  728. }
  729. .del-item-p{
  730. width:80px;
  731. line-height:40px;
  732. height:40px;
  733. text-align: center;
  734. background-color: #0045AF;
  735. color:#fff;
  736. border-top-right-radius: 4px;
  737. border-bottom-right-radius: 4px;
  738. }
  739. .tips-p{
  740. width:80px;
  741. line-height:40px;
  742. height:40px;
  743. text-align: center;
  744. background-color: #E0E0E0;
  745. color:#333;
  746. border-top-right-radius: 4px;
  747. border-bottom-right-radius: 4px;
  748. }
  749. }
  750. .item-box{
  751. }
  752. .del-position-p{
  753. z-index:10;
  754. position: absolute;
  755. top:10px;
  756. right: 10px;
  757. font-size:24px;
  758. color:#FF6666;
  759. cursor: pointer;
  760. }
  761. }
  762. }
  763. }
  764. }
  765. </style>