people_fireStation.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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. if (this.$route.query.addId) {
  206. const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
  207. if (this.membersList.length < MAX_LENGTH) {
  208. const newPerson = {
  209. name: '',
  210. userNum: '',
  211. phone: '',
  212. worker: '',
  213. // 其他字段
  214. };
  215. this.membersList.push(newPerson);
  216. } else {
  217. // 达到最大数量,给出提示或执行其他操作
  218. uni.showToast({
  219. title: '只支持一位添加',
  220. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  221. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  222. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  223. success() {
  224. // console.log('toast消息提示显示成功');
  225. },
  226. fail(err) {
  227. // console.error('toast消息提示显示失败', err);
  228. }
  229. });
  230. }
  231. }else{
  232. const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
  233. if (this.membersList.length < MAX_LENGTH) {
  234. const newPerson = {
  235. name: '',
  236. userNum: '',
  237. phone: '',
  238. worker: '',
  239. // 其他字段
  240. };
  241. this.membersList.push(newPerson);
  242. } else {
  243. // 达到最大数量,给出提示或执行其他操作
  244. uni.showToast({
  245. title: '超出限制',
  246. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  247. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  248. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  249. success() {
  250. // console.log('toast消息提示显示成功');
  251. },
  252. fail(err) {
  253. // console.error('toast消息提示显示失败', err);
  254. }
  255. });
  256. }
  257. }
  258. },
  259. addSure() {
  260. console.log(this.$route.query.addId, 'this.$route.query.addId');
  261. if (this.$route.query.addId) {
  262. if (!this.userRules && !this.phoneRules && !this.nameRules) {
  263. creatFirePeople({
  264. empName: this.membersList[0].name,
  265. empType: this.membersList[0].worker,
  266. idcardno: this.membersList[0].userNum,
  267. microstationid: this.fireStationId - 0,
  268. mobile: this.membersList[0].phone,
  269. }).then(res => {
  270. if (res.data) {
  271. this.getAllFire()
  272. uni.showToast({
  273. title: '添加成功',
  274. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  275. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  276. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  277. success() {
  278. // console.log('toast消息提示显示成功');
  279. },
  280. fail(err) {
  281. // console.error('toast消息提示显示失败', err);
  282. }
  283. });
  284. this.membersList = []
  285. }
  286. })
  287. } else {
  288. uni.showToast({
  289. title: '请检查表单项',
  290. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  291. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  292. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  293. success() {
  294. // console.log('toast消息提示显示成功');
  295. },
  296. fail(err) {
  297. // console.error('toast消息提示显示失败', err);
  298. }
  299. });
  300. }
  301. } else {
  302. // let ground = localStorage.getItem('empList')
  303. // if (ground) {
  304. // ground = JSON.parse(ground)
  305. // ground.push({
  306. // ...this.membersList[0]
  307. // })
  308. // localStorage.setItem('empList', JSON.stringify(ground))
  309. // } else {
  310. // localStorage.setItem("empList", JSON.stringify(this.membersList))
  311. // }
  312. localStorage.setItem("empList", JSON.stringify(this.membersList))
  313. uni.navigateBack({
  314. delta: 1
  315. })
  316. }
  317. },
  318. change(e) {
  319. this.membersList[0].worker = e
  320. // console.log("e:", e);
  321. },
  322. change1(e) {
  323. this.membersList[0].worker = e
  324. // console.log("e1:", e);
  325. },
  326. getbackid() {
  327. let x = localStorage.getItem('getUserInfo_key')
  328. x = JSON.parse(x)
  329. this.userId = x.data.userInfo.id
  330. getuserfireid({
  331. userId: this.userId
  332. }).then(res => {
  333. // console.log(res, 'userfire');
  334. })
  335. // console.log(x.data.userInfo.id, 'xxx');
  336. },
  337. getAllFire() {
  338. let num = 0
  339. if (this.$route.query.addId === '1') {
  340. num = '1'
  341. getfirepage({
  342. pageNo: 1,
  343. pageSize: 10,
  344. microstationid: this.fireStationId,
  345. empType: num
  346. }).then(res => {
  347. // console.log(res, '888');
  348. this.tableList = res.data.list
  349. })
  350. } else if (this.$route.query.addId === '2') {
  351. num = '2'
  352. getfirepage({
  353. pageNo: 1,
  354. pageSize: 10,
  355. microstationid: this.fireStationId,
  356. empType: num
  357. }).then(res => {
  358. // console.log(res, '888');
  359. this.tableList = res.data.list
  360. })
  361. } else if (this.$route.query.addId === '0') {
  362. num = '0'
  363. getfirepage({
  364. pageNo: 1,
  365. pageSize: 10,
  366. microstationid: this.fireStationId,
  367. empType: num
  368. }).then(res => {
  369. // console.log(res, '888');
  370. this.tableList = res.data.list
  371. })
  372. }
  373. },
  374. delUser(row) {
  375. this.show123 = true
  376. this.delId = row.id
  377. },
  378. makeSureDel() {
  379. },
  380. confirm() {
  381. delFirePeople(this.delId).then(res => {
  382. if (res.data) {
  383. uni.showToast({
  384. title: '删除成功',
  385. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  386. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  387. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  388. success() {
  389. // console.log('toast消息提示显示成功');
  390. },
  391. fail(err) {
  392. // console.error('toast消息提示显示失败', err);
  393. }
  394. });
  395. this.getAllFire()
  396. this.show123 = false
  397. }
  398. })
  399. },
  400. cancel() {
  401. this.show123 = false
  402. },
  403. close() {
  404. this.show123 = false
  405. },
  406. editUser(row) {
  407. this.editPeopleId = row.id
  408. getMesbyid({
  409. id: row.id
  410. }).then(res => {
  411. if (res.data) {
  412. this.formbox.fname = res.data.empName
  413. this.formbox.fphone = res.data.mobile
  414. this.formbox.fpower = res.data.empType
  415. // this.formbox.fworker = res.data.empType
  416. this.formbox.fuserNum = res.data.idcardno
  417. this.showModal = true
  418. }
  419. })
  420. },
  421. closeModal() {
  422. this.showModal = false
  423. },
  424. makeSureEdit() {
  425. editFirePeople({
  426. duty: this.formbox.fpower,
  427. empName: this.formbox.fname,
  428. // empType: this.formbox.fworker,
  429. id: this.editPeopleId,
  430. idcardno: this.formbox.fuserNum,
  431. microstationid: this.fireStationId - 0,
  432. mobile: this.formbox.fphone,
  433. }).then(res => {
  434. if (res.data) {
  435. this.showModal = false
  436. this.getAllFire()
  437. uni.showToast({
  438. title: '编辑成功',
  439. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  440. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  441. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  442. success() {
  443. // console.log('toast消息提示显示成功');
  444. },
  445. fail(err) {
  446. // console.error('toast消息提示显示失败', err);
  447. }
  448. });
  449. }
  450. // console.log(res, 'edit');
  451. })
  452. },
  453. // 对表单内name的正则判断
  454. nameBlur() {
  455. // console.log(this.membersList[0].name);
  456. if (this.membersList[0].name === '') {
  457. this.nameRules = true
  458. } else {
  459. this.nameRules = false
  460. }
  461. },
  462. userBlur() {
  463. 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]$/;
  464. if (regex.test(this.membersList[0].userNum)) {
  465. this.userRules = false
  466. } else {
  467. this.userRules = true
  468. }
  469. },
  470. phoneBlur() {
  471. const regex = /^1[3-9]\d{9}$/;
  472. if (regex.test(this.membersList[0].phone)) {
  473. this.phoneRules = false
  474. } else {
  475. this.phoneRules = true
  476. }
  477. },
  478. cleanList() {
  479. this.membersList = []
  480. let list = localStorage.getItem("empList")
  481. list = JSON.parse(list)
  482. if (list) {
  483. localStorage.removeItem('empList')
  484. }
  485. },
  486. // 读取本地缓存
  487. getGround() {
  488. let list = localStorage.getItem("empList")
  489. list = JSON.parse(list)
  490. if (list) {
  491. this.membersList = list
  492. } else {
  493. this.membersList = []
  494. }
  495. }
  496. },
  497. onLoad(options) {
  498. let ids = localStorage.getItem("fireId")
  499. if (ids) {
  500. this.fireStationId = ids
  501. }
  502. },
  503. onShow() {
  504. this.getTypePeople()
  505. this.getGround()
  506. if (this.$route.query.addId) {
  507. this.getAllFire()
  508. this.getbackid()
  509. // console.log(options, 'options')
  510. this.resultId = this.$route.query.addId
  511. if (this.resultId === '2') {
  512. this.tomole = '添加负责人'
  513. } else if (this.resultId === '1') {
  514. this.tomole = '添加值班人'
  515. } else {
  516. this.tomole = '添加人员信息'
  517. }
  518. // console.log(this.$route.query, 'query'); // 输出传递的参数值
  519. } else {
  520. return
  521. }
  522. },
  523. computed: {
  524. getDuty() {
  525. return (num) => {
  526. if (num === '1') {
  527. return '值班人';
  528. } else if (num === '2') {
  529. return '站长';
  530. } else {
  531. return '普通人员';
  532. }
  533. };
  534. }
  535. }
  536. }
  537. </script>
  538. <style lang="scss" scoped>
  539. .uni-container {
  540. padding: 10px;
  541. background: #fff;
  542. // z-index: 9999999;
  543. position: relative;
  544. }
  545. /deep/ .typeStyle {
  546. width: 650rpx !important;
  547. }
  548. /deep/ .antherStyle {
  549. width: 630rpx;
  550. height: 100rpx;
  551. margin-left: 20rpx;
  552. }
  553. /deep/ .antherBtn {
  554. width: 200rpx;
  555. height: 80rpx;
  556. margin-bottom: 30rpx;
  557. background-color: #4DB1B6;
  558. color: white;
  559. text-align: center;
  560. line-height: 80rpx;
  561. font-size: 30rpx;
  562. border-radius: 20rpx;
  563. }
  564. .tableBox {
  565. width: 90%;
  566. height: auto;
  567. margin: 20rpx auto;
  568. margin-left: 40rpx;
  569. /* background-color: aqua; */
  570. }
  571. .custom-table {
  572. border-collapse: collapse;
  573. /* 合并边框 */
  574. }
  575. .custom-table th,
  576. .custom-table td {
  577. /* width: 39.5%; */
  578. border: 1px solid #4DB1B6;
  579. /* 添加边框样式 */
  580. padding: 8px;
  581. /* 设置单元格内边距 */
  582. }
  583. .aTd {
  584. /* width: 60%; */
  585. }
  586. .editBtn {
  587. width: 120rpx;
  588. height: 60rpx;
  589. background-color: #4DB1B6;
  590. color: white;
  591. text-align: center;
  592. line-height: 60rpx;
  593. border-radius: 10rpx;
  594. font-size: 20rpx;
  595. margin-bottom: 10rpx;
  596. margin-right: 10rpx;
  597. }
  598. .modalBox {
  599. width: 700rpx;
  600. height: 750rpx;
  601. /deep/.uni-select {
  602. width: 100%;
  603. height: 50px;
  604. border: 1px solid #4DB1B6;
  605. }
  606. /deep/ .u-line{
  607. border:none !important;
  608. }
  609. /deep/ .uni-input-input{
  610. padding: 0 10rpx;
  611. }
  612. /deep/ .u-form-item__body{
  613. width: 90%;
  614. }
  615. }
  616. .insides {
  617. width: 400rpx;
  618. height: 100rpx;
  619. border: 1px solid #4DB1B6;
  620. }
  621. .useBox {
  622. display: flex;
  623. justify-content: space-around;
  624. align-items: center;
  625. margin-top: 20rpx;
  626. }
  627. .erroring {
  628. color: red;
  629. font-size: 20rpx;
  630. }
  631. .circleBtn {
  632. width: 100rpx;
  633. height: 100rpx;
  634. border-radius: 50%;
  635. font-size: 90rpx;
  636. text-align: center;
  637. line-height: 100rpx;
  638. color: white;
  639. background-color: #4EB0B5;
  640. position: fixed;
  641. bottom: 20rpx;
  642. right: 20rpx;
  643. }
  644. .cardBox {
  645. width: 650rpx;
  646. margin: 100rpx auto 20rpx;
  647. border-radius: 30rpx;
  648. }
  649. .u-form-item__body__left {
  650. width: 100rpx;
  651. }
  652. /deep/.u-button--primary {
  653. border: none
  654. }
  655. </style>