people_fireStation.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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" @blur="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 @blur="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" @blur="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.power" :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. fpower: '',
  167. },
  168. editPeopleId: '', //需要修改人员的id
  169. nameRules: false, //对name的正则验证
  170. userRules: false, //对身份证的正则验证
  171. phoneRules: false, //对电话的正则验证
  172. showDel: false,
  173. delId: '',
  174. show123:false,
  175. }
  176. },
  177. methods: {
  178. addNewPeople() {
  179. const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
  180. if (this.membersList.length < MAX_LENGTH) {
  181. const newPerson = {
  182. name: '',
  183. userNum: '',
  184. phone: '',
  185. worker: '',
  186. power: '',
  187. // 其他字段
  188. };
  189. this.membersList.push(newPerson);
  190. } else {
  191. // 达到最大数量,给出提示或执行其他操作
  192. uni.showToast({
  193. title: '只支持一位添加',
  194. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  195. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  196. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  197. success() {
  198. // console.log('toast消息提示显示成功');
  199. },
  200. fail(err) {
  201. // console.error('toast消息提示显示失败', err);
  202. }
  203. });
  204. }
  205. },
  206. addSure() {
  207. if (this.$route.query.addId) {
  208. if (!this.userRules && !this.phoneRules && !this.nameRules) {
  209. creatFirePeople({
  210. duty: this.membersList[0].power,
  211. empName: this.membersList[0].name,
  212. // empType: this.membersList[0].worker,
  213. idcardno: this.membersList[0].userNum,
  214. microstationid: this.fireStationId - 0,
  215. mobile: this.membersList[0].phone,
  216. }).then(res => {
  217. if (res.data) {
  218. this.getAllFire()
  219. uni.showToast({
  220. title: '添加成功',
  221. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  222. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  223. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  224. success() {
  225. // console.log('toast消息提示显示成功');
  226. },
  227. fail(err) {
  228. // console.error('toast消息提示显示失败', err);
  229. }
  230. });
  231. this.membersList = []
  232. }
  233. })
  234. } else {
  235. uni.showToast({
  236. title: '请检查表单项',
  237. icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
  238. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  239. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  240. success() {
  241. // console.log('toast消息提示显示成功');
  242. },
  243. fail(err) {
  244. // console.error('toast消息提示显示失败', err);
  245. }
  246. });
  247. }
  248. } else {
  249. localStorage.setItem("empList", JSON.stringify(this.membersList))
  250. uni.navigateBack({
  251. delta: 1
  252. })
  253. }
  254. },
  255. change(e) {
  256. // console.log("e:", e);
  257. },
  258. change1(e) {
  259. // console.log("e:", e);
  260. },
  261. getbackid() {
  262. let x = localStorage.getItem('getUserInfo_key')
  263. x = JSON.parse(x)
  264. this.userId = x.data.userInfo.id
  265. getuserfireid({
  266. userId: this.userId
  267. }).then(res => {
  268. // console.log(res, 'userfire');
  269. })
  270. // console.log(x.data.userInfo.id, 'xxx');
  271. },
  272. getAllFire() {
  273. let num = 0
  274. if (this.$route.query.addId === '1') {
  275. num = '1'
  276. getfirepage({
  277. pageNo: 1,
  278. pageSize: 10,
  279. microstationid: this.fireStationId,
  280. duty: num
  281. }).then(res => {
  282. // console.log(res, '888');
  283. this.tableList = res.data.list
  284. })
  285. } else if (this.$route.query.addId === '2') {
  286. num = '2'
  287. getfirepage({
  288. pageNo: 1,
  289. pageSize: 10,
  290. microstationid: this.fireStationId,
  291. duty: num
  292. }).then(res => {
  293. // console.log(res, '888');
  294. this.tableList = res.data.list
  295. })
  296. } else if (this.$route.query.addId === '0') {
  297. num = '0'
  298. getfirepage({
  299. pageNo: 1,
  300. pageSize: 10,
  301. microstationid: this.fireStationId,
  302. duty: num
  303. }).then(res => {
  304. // console.log(res, '888');
  305. this.tableList = res.data.list
  306. })
  307. }
  308. },
  309. delUser(row) {
  310. this.show123 = true
  311. this.delId = row.id
  312. },
  313. makeSureDel() {
  314. },
  315. confirm() {
  316. delFirePeople(this.delId).then(res => {
  317. if (res.data) {
  318. uni.showToast({
  319. title: '删除成功',
  320. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  321. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  322. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  323. success() {
  324. // console.log('toast消息提示显示成功');
  325. },
  326. fail(err) {
  327. // console.error('toast消息提示显示失败', err);
  328. }
  329. });
  330. this.getAllFire()
  331. this.show123 = false
  332. }
  333. })
  334. },
  335. cancel(){
  336. this.show123 = false
  337. },
  338. close() {
  339. this.show123 = false
  340. },
  341. editUser(row) {
  342. this.editPeopleId = row.id
  343. getMesbyid({
  344. id: row.id
  345. }).then(res => {
  346. if (res.data) {
  347. this.formbox.fname = res.data.empName
  348. this.formbox.fphone = res.data.mobile
  349. this.formbox.fpower = res.data.duty
  350. // this.formbox.fworker = res.data.empType
  351. this.formbox.fuserNum = res.data.idcardno
  352. this.showModal = true
  353. }
  354. })
  355. },
  356. closeModal() {
  357. this.showModal = false
  358. },
  359. makeSureEdit() {
  360. editFirePeople({
  361. duty: this.formbox.fpower,
  362. empName: this.formbox.fname,
  363. // empType: this.formbox.fworker,
  364. id: this.editPeopleId,
  365. idcardno: this.formbox.fuserNum,
  366. microstationid: this.fireStationId - 0,
  367. mobile: this.formbox.fphone,
  368. }).then(res => {
  369. if (res.data) {
  370. this.showModal = false
  371. this.getAllFire()
  372. uni.showToast({
  373. title: '编辑成功',
  374. icon: 'success', // 图标类型,可选值:'success', 'loading', 'none'
  375. duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
  376. mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
  377. success() {
  378. // console.log('toast消息提示显示成功');
  379. },
  380. fail(err) {
  381. // console.error('toast消息提示显示失败', err);
  382. }
  383. });
  384. }
  385. // console.log(res, 'edit');
  386. })
  387. },
  388. // 对表单内name的正则判断
  389. nameBlur() {
  390. // console.log(this.membersList[0].name);
  391. if (this.membersList[0].name === '') {
  392. this.nameRules = true
  393. } else {
  394. this.nameRules = false
  395. }
  396. },
  397. userBlur() {
  398. 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]$/;
  399. if (regex.test(this.membersList[0].userNum)) {
  400. this.userRules = false
  401. } else {
  402. this.userRules = true
  403. }
  404. },
  405. phoneBlur() {
  406. const regex = /^1[3-9]\d{9}$/;
  407. if (regex.test(this.membersList[0].phone)) {
  408. this.phoneRules = false
  409. } else {
  410. this.phoneRules = true
  411. }
  412. },
  413. cleanList() {
  414. this.membersList = []
  415. }
  416. },
  417. onLoad(options) {
  418. let ids = localStorage.getItem("fireId")
  419. if (ids) {
  420. this.fireStationId = ids
  421. }
  422. },
  423. onShow() {
  424. if (this.$route.query.addId) {
  425. this.getAllFire()
  426. this.getbackid()
  427. // console.log(options, 'options')
  428. this.resultId = this.$route.query.addId
  429. if (this.resultId === '2') {
  430. this.tomole = '添加负责人'
  431. } else if (this.resultId === '1') {
  432. this.tomole = '添加值班人'
  433. } else {
  434. this.tomole = '添加人员信息'
  435. }
  436. // console.log(this.$route.query, 'query'); // 输出传递的参数值
  437. } else {
  438. return
  439. }
  440. },
  441. computed: {
  442. getDuty() {
  443. return (num) => {
  444. if (num === '1') {
  445. return '值班人';
  446. } else if (num === '2') {
  447. return '负责人';
  448. } else {
  449. return '普通人员';
  450. }
  451. };
  452. }
  453. }
  454. }
  455. </script>
  456. <style>
  457. /deep/ .typeStyle {
  458. width: 650rpx !important;
  459. }
  460. /deep/ .antherStyle {
  461. width: 630rpx;
  462. height: 100rpx;
  463. margin-left: 20rpx;
  464. }
  465. /deep/ .antherBtn {
  466. width: 200rpx;
  467. height: 50rpx;
  468. margin-bottom: 30rpx;
  469. background-color: #4DB1B6;
  470. color: white;
  471. text-align: center;
  472. line-height: 50rpx;
  473. font-size: 30rpx;
  474. border-radius: 20rpx;
  475. }
  476. .tableBox {
  477. width: 90%;
  478. height: auto;
  479. margin: 20rpx auto;
  480. margin-left: 40rpx;
  481. /* background-color: aqua; */
  482. }
  483. .custom-table {
  484. border-collapse: collapse;
  485. /* 合并边框 */
  486. }
  487. .custom-table th,
  488. .custom-table td {
  489. /* width: 39.5%; */
  490. border: 1px solid #4DB1B6;
  491. /* 添加边框样式 */
  492. padding: 8px;
  493. /* 设置单元格内边距 */
  494. }
  495. .aTd {
  496. /* width: 60%; */
  497. }
  498. .editBtn {
  499. width: 100rpx;
  500. height: 60rpx;
  501. background-color: #4DB1B6;
  502. color: white;
  503. text-align: center;
  504. line-height: 60rpx;
  505. border-radius: 10rpx;
  506. font-size: 20rpx;
  507. margin-bottom: 10rpx;
  508. margin-right: 10rpx;
  509. }
  510. .modalBox {
  511. width: 700rpx;
  512. height: 880rpx;
  513. }
  514. .insides {
  515. width: 400rpx;
  516. height: 100rpx;
  517. border: 1px solid #4DB1B6;
  518. }
  519. .useBox {
  520. display: flex;
  521. justify-content: space-around;
  522. align-items: center;
  523. margin-top: 20rpx;
  524. }
  525. .erroring {
  526. color: red;
  527. font-size: 20rpx;
  528. }
  529. .circleBtn {
  530. width: 100rpx;
  531. height: 100rpx;
  532. border-radius: 50%;
  533. font-size: 90rpx;
  534. text-align: center;
  535. line-height: 100rpx;
  536. color: white;
  537. background-color: #4EB0B5;
  538. position: absolute;
  539. top: 1300rpx;
  540. left: 590rpx;
  541. }
  542. .cardBox {
  543. width: 650rpx;
  544. margin: 30rpx auto;
  545. border-radius: 30rpx;
  546. }
  547. .u-form-item__body__left{
  548. width: 100rpx;
  549. }
  550. </style>