people_fireStation.vue 16 KB

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