people_fireStation.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view style="position: relative;">
  3. <navInfo :title="'编辑人员'"></navInfo>
  4. <view class="bgTopImg" style="height:200rpx;">
  5. <image slot="right" class="bgTopImg"></image>
  6. </view>
  7. <div class="cardBox">
  8. <uni-card v-for="item in tableList" style="border: 2rpx solid #4DB1B6;">
  9. <div style="display: flex;justify-content: space-between;align-items: center;">
  10. <div>
  11. <text>姓名:{{item.empName}}</text><br>
  12. <text>电话:{{ item.mobile }}</text><br>
  13. <text>身份证号:{{item.idcardno}}</text><br>
  14. <text>职务:{{getDuty(item.empType)}}</text>
  15. </div>
  16. <div style="display: flex;justify-content: space-around;align-items: center;">
  17. <button @click="delUser(item)" class="editBtn" style="background-color: red;">删除</button>
  18. <button @click="editUser(item)" class="editBtn">编辑</button>
  19. </div>
  20. </div>
  21. </uni-card>
  22. </div>
  23. <!-- 新增的人员表单项 -->
  24. <div v-for="(person, index) in membersList" :key="index"
  25. style="border-bottom: 1px solid black;margin-top: 100rpx;">
  26. <u--form ref="forms">
  27. <u-form-item class="typeStyle" :prop="'name' + (index + 1)">
  28. <p style="width: 150rpx;margin-left: 20rpx;">姓名</p>
  29. <u-input v-model="person.name" id="nameId" @change="nameBlur" :placeholder="'请输入姓名'" />
  30. <span class="erroring" v-if="nameRules">请输入名称</span>
  31. </u-form-item>
  32. <u-form-item class="typeStyle" :prop="'age' + (index + 1)">
  33. <p style="width: 150rpx;margin-left: 20rpx;">身份证号</p>
  34. <u-input @change="userBlur" v-model="person.userNum" :placeholder="'请输入身份证号'" />
  35. <span class="erroring" v-if="userRules">身份证号有误</span>
  36. </u-form-item>
  37. <!-- 其他人员信息字段 -->
  38. <u-form-item class="typeStyle" :prop="'age' + (index + 1)">
  39. <p style="width: 150rpx;margin-left: 20rpx;">电话号</p>
  40. <u-input v-model="person.phone" @change="phoneBlur" :placeholder="'请输入电话号'" />
  41. <span class="erroring" v-if="phoneRules">电话号有误</span>
  42. </u-form-item>
  43. <!-- <u-form-item class="typeStyle" :prop="'age' + (index + 1)">
  44. <p style="width: 150rpx;margin-left: 20rpx;">人员类型</p>
  45. <u-input v-model="person.worker" :placeholder="'请输入人员类型'" />
  46. </u-form-item> -->
  47. <u-form-item class="antherStyle">
  48. <p style="width: 150rpx;">人员类型</p>
  49. <uni-data-select v-model="person.power" :localdata="selectType" @change="change"></uni-data-select>
  50. <!-- <uni-data-select v-model="person.worker" :localdata="range" @change="change"></uni-data-select> -->
  51. </u-form-item>
  52. <u-form-item>
  53. <u-button type="primary" @click="addSure" class="antherBtn">提交</u-button>
  54. <u-button type="primary" @click="cleanList" class="antherBtn">取消</u-button>
  55. </u-form-item>
  56. </u--form>
  57. </div>
  58. <div>
  59. <u-popup :show="showModal" mode="center" @close="closeModal" :round="10">
  60. <view class="modalBox">
  61. <u--form labelPosition="left" :model="formbox" ref="uForm" style="width: 100%;">
  62. <u-form-item style="width: 400rpx;" label="姓名" prop="formbox.fname" borderBottom ref="item1">
  63. <u--input class="insides" v-model="formbox.fname" border="none"></u--input>
  64. </u-form-item>
  65. <u-form-item style="width: 350rpx;" label="电话号" prop="formbox.fphone" borderBottom ref="item1">
  66. <u--input class="insides" v-model="formbox.fphone" border="none"></u--input>
  67. </u-form-item>
  68. <u-form-item style="width: 490rpx;" label="人员类型" prop="formbox.fpower" borderBottom ref="item1">
  69. <uni-data-select v-model="formbox.fpower" :localdata="selectType"
  70. @change="change1"></uni-data-select>
  71. </u-form-item>
  72. <u-form-item style="width: 350rpx;" label="身份证号" prop="userInfo.fuserNum" borderBottom
  73. ref="item1">
  74. <u--input class="insides" v-model="formbox.fuserNum" border="none"></u--input>
  75. </u-form-item>
  76. <!-- <u-form-item style="width: 350rpx;" label="人员类型" prop="userInfo.fworker" borderBottom
  77. ref="item1">
  78. <u--input class="insides" v-model="formbox.fworker" border="none"></u--input>
  79. </u-form-item> -->
  80. </u--form>
  81. <div class="useBox">
  82. <button class="antherBtn" @click="makeSureEdit">确认修改</button>
  83. <button class="antherBtn" @click="showModal = false">取消</button>
  84. </div>
  85. </view>
  86. </u-popup>
  87. </div>
  88. <div>
  89. <u-popup :show="showDel" title="确认删除?" mode="center">
  90. <div style="width: 400rpx;height: 200rpx;margin: 20rpx 20rpx;">
  91. <p style="font-size: 35rpx;color: black;">是否删除该数据项?</p>
  92. <p style="font-size: 20rpx;color: gray;">确认删除?</p>
  93. <div style="display: flex;justify-content: space-around;align-items: center;margin-top: 40rpx;">
  94. <button class="antherBtn" @click="makeSureDel" style="background-color: red;">确认</button>
  95. <button class="antherBtn" @click="showDel = false">取消</button>
  96. </div>
  97. </div>
  98. </u-popup>
  99. </div>
  100. <div>
  101. <u-modal :show="show123" @confirm="confirm" @cancel="cancel" @close="close" asyncClose closeOnClickOverlay
  102. showCancelButton confirmColor="red" title="是否删除该数据项" content="确认删除?" ref="uModal"></u-modal>
  103. </div>
  104. <button @click="addNewPeople" class="circleBtn">+</button>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. creatFirePeople,
  110. delFirePeople,
  111. outexcel,
  112. getMesbyid,
  113. getfirelist,
  114. getfirepage,
  115. editFirePeople,
  116. getuserfireid
  117. } from "../../../../api/peoplefire/index.js"
  118. import {
  119. getDict
  120. } from "../../../../api/dictName/index.js"
  121. import config from '@/config'
  122. const baseUrlImg = config.baseUrlImg
  123. import navInfo from '@/pagesA/components/my-nav/nav'
  124. export default {
  125. components: {
  126. navInfo
  127. },
  128. data() {
  129. return {
  130. membersList: [], //添加的人员数组
  131. resultId: '',
  132. value: 0,
  133. range: [{
  134. value: '2',
  135. text: "站长"
  136. },
  137. {
  138. value: '1',
  139. text: "值班人员"
  140. },
  141. {
  142. value: '0',
  143. text: "普通人员"
  144. },
  145. ],
  146. range1: [{
  147. value: '2',
  148. text: "负责人"
  149. },
  150. {
  151. value: '1',
  152. text: "值班人员"
  153. },
  154. {
  155. value: '0',
  156. text: "普通人员"
  157. },
  158. ],
  159. tomole: "添加人员",
  160. tableList: [], //显示的人员数组
  161. userId: '', //用户id
  162. smallFireId: '',
  163. fireStationId: 0, //消防站id
  164. showModal: false, //模态框开关
  165. formbox: {
  166. fname: '',
  167. fphone: '',
  168. fworker: '',
  169. fuserNum: '',
  170. },
  171. editPeopleId: '', //需要修改人员的id
  172. nameRules: false, //对name的正则验证
  173. userRules: false, //对身份证的正则验证
  174. phoneRules: false, //对电话的正则验证
  175. showDel: false,
  176. delId: '',
  177. show123: false,
  178. selectType: [], //选项
  179. }
  180. },
  181. methods: {
  182. getTypePeople() {
  183. getDict({
  184. pageNo: 1,
  185. pageSize: 10,
  186. dictType: "micro_emp_type"
  187. }).then(res => {
  188. this.selectType = res.data.list.map(item => {
  189. return {
  190. value: item.value,
  191. text: item.label
  192. }
  193. })
  194. })
  195. },
  196. addNewPeople() {
  197. const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
  198. if (this.membersList.length < MAX_LENGTH) {
  199. const newPerson = {
  200. name: '',
  201. userNum: '',
  202. phone: '',
  203. worker: '',
  204. // 其他字段
  205. };
  206. this.membersList.push(newPerson);
  207. } else {
  208. // 达到最大数量,给出提示或执行其他操作
  209. uni.showToast({
  210. title: '只支持一位添加',
  211. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  212. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  213. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  214. success() {
  215. // console.log('toast消息提示显示成功');
  216. },
  217. fail(err) {
  218. // console.error('toast消息提示显示失败', err);
  219. }
  220. });
  221. }
  222. },
  223. addSure() {
  224. if (this.$route.query.addId) {
  225. if (!this.userRules && !this.phoneRules && !this.nameRules) {
  226. console.log(this.membersList[0].worker,'988');
  227. creatFirePeople({
  228. empName: this.membersList[0].name,
  229. empType: this.membersList[0].worker,
  230. idcardno: this.membersList[0].userNum,
  231. microstationid: this.fireStationId - 0,
  232. mobile: this.membersList[0].phone,
  233. }).then(res => {
  234. if (res.data) {
  235. this.getAllFire()
  236. uni.showToast({
  237. title: '添加成功',
  238. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  239. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  240. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  241. success() {
  242. // console.log('toast消息提示显示成功');
  243. },
  244. fail(err) {
  245. // console.error('toast消息提示显示失败', err);
  246. }
  247. });
  248. this.membersList = []
  249. }
  250. })
  251. } else {
  252. uni.showToast({
  253. title: '请检查表单项',
  254. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  255. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  256. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  257. success() {
  258. // console.log('toast消息提示显示成功');
  259. },
  260. fail(err) {
  261. // console.error('toast消息提示显示失败', err);
  262. }
  263. });
  264. }
  265. } else {
  266. localStorage.setItem("empList", JSON.stringify(this.membersList))
  267. uni.navigateBack({
  268. delta: 1
  269. })
  270. }
  271. },
  272. change(e) {
  273. this.membersList[0].worker = e
  274. // console.log("e:", e);
  275. },
  276. change1(e) {
  277. this.membersList[0].worker = e
  278. // console.log("e1:", e);
  279. },
  280. getbackid() {
  281. let x = localStorage.getItem('getUserInfo_key')
  282. x = JSON.parse(x)
  283. this.userId = x.data.userInfo.id
  284. getuserfireid({
  285. userId: this.userId
  286. }).then(res => {
  287. // console.log(res, 'userfire');
  288. })
  289. // console.log(x.data.userInfo.id, 'xxx');
  290. },
  291. getAllFire() {
  292. let num = 0
  293. if (this.$route.query.addId === '1') {
  294. num = '1'
  295. getfirepage({
  296. pageNo: 1,
  297. pageSize: 10,
  298. microstationid: this.fireStationId,
  299. empType: num
  300. }).then(res => {
  301. // console.log(res, '888');
  302. this.tableList = res.data.list
  303. })
  304. } else if (this.$route.query.addId === '2') {
  305. num = '2'
  306. getfirepage({
  307. pageNo: 1,
  308. pageSize: 10,
  309. microstationid: this.fireStationId,
  310. empType: num
  311. }).then(res => {
  312. // console.log(res, '888');
  313. this.tableList = res.data.list
  314. })
  315. } else if (this.$route.query.addId === '0') {
  316. num = '0'
  317. getfirepage({
  318. pageNo: 1,
  319. pageSize: 10,
  320. microstationid: this.fireStationId,
  321. empType: num
  322. }).then(res => {
  323. // console.log(res, '888');
  324. this.tableList = res.data.list
  325. })
  326. }
  327. },
  328. delUser(row) {
  329. this.show123 = true
  330. this.delId = row.id
  331. },
  332. makeSureDel() {
  333. },
  334. confirm() {
  335. delFirePeople(this.delId).then(res => {
  336. if (res.data) {
  337. uni.showToast({
  338. title: '删除成功',
  339. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  340. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  341. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  342. success() {
  343. // console.log('toast消息提示显示成功');
  344. },
  345. fail(err) {
  346. // console.error('toast消息提示显示失败', err);
  347. }
  348. });
  349. this.getAllFire()
  350. this.show123 = false
  351. }
  352. })
  353. },
  354. cancel() {
  355. this.show123 = false
  356. },
  357. close() {
  358. this.show123 = false
  359. },
  360. editUser(row) {
  361. this.editPeopleId = row.id
  362. getMesbyid({
  363. id: row.id
  364. }).then(res => {
  365. if (res.data) {
  366. this.formbox.fname = res.data.empName
  367. this.formbox.fphone = res.data.mobile
  368. this.formbox.fpower = res.data.empType
  369. // this.formbox.fworker = res.data.empType
  370. this.formbox.fuserNum = res.data.idcardno
  371. this.showModal = true
  372. }
  373. })
  374. },
  375. closeModal() {
  376. this.showModal = false
  377. },
  378. makeSureEdit() {
  379. editFirePeople({
  380. duty: this.formbox.fpower,
  381. empName: this.formbox.fname,
  382. // empType: this.formbox.fworker,
  383. id: this.editPeopleId,
  384. idcardno: this.formbox.fuserNum,
  385. microstationid: this.fireStationId - 0,
  386. mobile: this.formbox.fphone,
  387. }).then(res => {
  388. if (res.data) {
  389. this.showModal = false
  390. this.getAllFire()
  391. uni.showToast({
  392. title: '编辑成功',
  393. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  394. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  395. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  396. success() {
  397. // console.log('toast消息提示显示成功');
  398. },
  399. fail(err) {
  400. // console.error('toast消息提示显示失败', err);
  401. }
  402. });
  403. }
  404. // console.log(res, 'edit');
  405. })
  406. },
  407. // 对表单内name的正则判断
  408. nameBlur() {
  409. // console.log(this.membersList[0].name);
  410. if (this.membersList[0].name === '') {
  411. this.nameRules = true
  412. } else {
  413. this.nameRules = false
  414. }
  415. },
  416. userBlur() {
  417. const regex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}[\dxX]$/;
  418. if (regex.test(this.membersList[0].userNum)) {
  419. this.userRules = false
  420. } else {
  421. this.userRules = true
  422. }
  423. },
  424. phoneBlur() {
  425. const regex = /^1[3-9]\d{9}$/;
  426. if (regex.test(this.membersList[0].phone)) {
  427. this.phoneRules = false
  428. } else {
  429. this.phoneRules = true
  430. }
  431. },
  432. cleanList() {
  433. this.membersList = []
  434. let list = localStorage.getItem("empList")
  435. list = JSON.parse(list)
  436. if (list) {
  437. localStorage.removeItem('empList')
  438. }
  439. },
  440. // 读取本地缓存
  441. getGround() {
  442. let list = localStorage.getItem("empList")
  443. list = JSON.parse(list)
  444. if (list) {
  445. this.membersList = list
  446. } else {
  447. this.membersList = []
  448. }
  449. }
  450. },
  451. onLoad(options) {
  452. let ids = localStorage.getItem("fireId")
  453. if (ids) {
  454. this.fireStationId = ids
  455. }
  456. },
  457. onShow() {
  458. this.getTypePeople()
  459. this.getGround()
  460. if (this.$route.query.addId) {
  461. this.getAllFire()
  462. this.getbackid()
  463. // console.log(options, 'options')
  464. this.resultId = this.$route.query.addId
  465. if (this.resultId === '2') {
  466. this.tomole = '添加负责人'
  467. } else if (this.resultId === '1') {
  468. this.tomole = '添加值班人'
  469. } else {
  470. this.tomole = '添加人员信息'
  471. }
  472. // console.log(this.$route.query, 'query'); // 输出传递的参数值
  473. } else {
  474. return
  475. }
  476. },
  477. computed: {
  478. getDuty() {
  479. return (num) => {
  480. if (num === '1') {
  481. return '值班人';
  482. } else if (num === '2') {
  483. return '站长';
  484. } else {
  485. return '普通人员';
  486. }
  487. };
  488. }
  489. }
  490. }
  491. </script>
  492. <style>
  493. /deep/ .typeStyle {
  494. width: 650rpx !important;
  495. }
  496. /deep/ .antherStyle {
  497. width: 630rpx;
  498. height: 100rpx;
  499. margin-left: 20rpx;
  500. }
  501. /deep/ .antherBtn {
  502. width: 200rpx;
  503. height: 50rpx;
  504. margin-bottom: 30rpx;
  505. background-color: #4DB1B6;
  506. color: white;
  507. text-align: center;
  508. line-height: 50rpx;
  509. font-size: 30rpx;
  510. border-radius: 20rpx;
  511. }
  512. .tableBox {
  513. width: 90%;
  514. height: auto;
  515. margin: 20rpx auto;
  516. margin-left: 40rpx;
  517. /* background-color: aqua; */
  518. }
  519. .custom-table {
  520. border-collapse: collapse;
  521. /* 合并边框 */
  522. }
  523. .custom-table th,
  524. .custom-table td {
  525. /* width: 39.5%; */
  526. border: 1px solid #4DB1B6;
  527. /* 添加边框样式 */
  528. padding: 8px;
  529. /* 设置单元格内边距 */
  530. }
  531. .aTd {
  532. /* width: 60%; */
  533. }
  534. .editBtn {
  535. width: 100rpx;
  536. height: 60rpx;
  537. background-color: #4DB1B6;
  538. color: white;
  539. text-align: center;
  540. line-height: 60rpx;
  541. border-radius: 10rpx;
  542. font-size: 20rpx;
  543. margin-bottom: 10rpx;
  544. margin-right: 10rpx;
  545. }
  546. .modalBox {
  547. width: 700rpx;
  548. height: 880rpx;
  549. }
  550. .insides {
  551. width: 400rpx;
  552. height: 100rpx;
  553. border: 1px solid #4DB1B6;
  554. }
  555. .useBox {
  556. display: flex;
  557. justify-content: space-around;
  558. align-items: center;
  559. margin-top: 20rpx;
  560. }
  561. .erroring {
  562. color: red;
  563. font-size: 20rpx;
  564. }
  565. .circleBtn {
  566. width: 100rpx;
  567. height: 100rpx;
  568. border-radius: 50%;
  569. font-size: 90rpx;
  570. text-align: center;
  571. line-height: 100rpx;
  572. color: white;
  573. background-color: #4EB0B5;
  574. position: absolute;
  575. top: 1300rpx;
  576. left: 590rpx;
  577. }
  578. .cardBox {
  579. width: 650rpx;
  580. margin: 30rpx auto;
  581. border-radius: 30rpx;
  582. }
  583. .u-form-item__body__left {
  584. width: 100rpx;
  585. }
  586. </style>