people_fireStation.vue 17 KB

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