vote.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="container">
  3. <!-- 顶部标题栏 -->
  4. <view class="header">
  5. <text class="header-title">盐龙街道住宅小区物业公司选聘调研</text>
  6. </view>
  7. <u--form labelPosition="left" :model="inputForm" :rules="rules" ref="uForm" labelWidth="80">
  8. <!-- 小区名称选择 -->
  9. <u-form-item label="小区" :borderBottom="true" prop="communityId1" required>
  10. <zxz-uni-data-select v-model="inputForm.communityId1" :localdata="communityList" @change="change1"
  11. :filterable='true' placeholder="请选择小区"></zxz-uni-data-select>
  12. </u-form-item>
  13. <!-- 楼栋号选择 -->
  14. <u-form-item label="楼栋号" :borderBottom="true" prop="communityId2" required>
  15. <zxz-uni-data-select v-model="inputForm.communityId2" :localdata="buildingList" @change="change2"
  16. :filterable='true' mode="none" placeholder="请选择楼栋号"></zxz-uni-data-select>
  17. </u-form-item>
  18. <!-- 房间号选择 -->
  19. <u-form-item label="房间号" prop="communityId3" required>
  20. <zxz-uni-data-select v-model="inputForm.communityId3" :localdata="roomList" :filterable='true'
  21. mode="none" placeholder="请选择房间号"></zxz-uni-data-select>
  22. </u-form-item>
  23. <!-- 房产持有人分割线 -->
  24. <view class="section-divider">
  25. <text class="divider-text">房产持有人</text>
  26. </view>
  27. <!-- 姓名输入 -->
  28. <u-form-item label="姓名" :borderBottom="true" prop="householder.name" required>
  29. <u-input v-model="inputForm.householder.name" @input="handleInput1" placeholder="请输入姓名" type="text" border="none"></u-input>
  30. </u-form-item>
  31. <!-- 身份证号后四位 -->
  32. <u-form-item label="身份证号 后4位" :borderBottom="true" prop="householder.cardNo" required>
  33. <yh-code-input mode="line" v-model="inputForm.householder.cardNo"></yh-code-input>
  34. </u-form-item>
  35. <!-- 联系电话 -->
  36. <u-form-item label="联系电话" :borderBottom="true" prop="phone">
  37. <u-input v-model="inputForm.householder.phone" placeholder="请输入联系电话号码" type="number" maxlength="11"
  38. border="none"></u-input>
  39. </u-form-item>
  40. <!-- 征求意见分割线 -->
  41. <view class="section-divider">
  42. <text class="divider-text">征求意见</text>
  43. <text class="divider-tag">(单选)</text>
  44. </view>
  45. <!-- 投票选项 -->
  46. <view class="vote-options">
  47. <u-radio-group v-model="inputForm.voteName" @change="groupChange" iconPlacement="right"
  48. placement="column">
  49. <u-radio labelSize="18" shape="circle" activeColor="#00aaff" inactiveColor="#CCCCCC" class="radio-item"
  50. v-for="(item, index) in voteOptions" :key="index" :label="item.name" :name="item.name">
  51. </u-radio>
  52. </u-radio-group>
  53. <u-input v-if="inputForm.vote==='4'" :showWordLimit="true" maxlength="20" v-model="inputForm.other" placeholder="请输入满意的物业公司名称"
  54. type="text"></u-input>
  55. </view>
  56. <!-- 物业管理建议 -->
  57. <view class="suggestion-section">
  58. <text class="suggestion-label">对物业管理有什么建议:</text>
  59. <u--textarea v-model="inputForm.suggestion" placeholder="请输入你对物业管理的建议"></u--textarea>
  60. </view>
  61. <!-- 提交按钮 -->
  62. <view class="submit-btn-container">
  63. <u-button class="submit-btn" @click="submitForm" :loading="isLoading" loadingText="提交中" shape="circle">
  64. 提交
  65. </u-button>
  66. </view>
  67. </u--form>
  68. </view>
  69. </template>
  70. <script>
  71. import voteRecordService from "@/api/vote/voteRecordService.js"
  72. import communityService from "@/api/vote/communityService.js"
  73. import yhCodeInput from '../components/yh-code-input/yh-code-input.vue';
  74. export default {
  75. components:{
  76. yhCodeInput
  77. },
  78. data() {
  79. return {
  80. inputForm: {
  81. id: '',
  82. communityId1: '',
  83. communityId2: '',
  84. communityId3: '',
  85. communityName: '',
  86. communityName1: '',
  87. householder: {
  88. id: ''
  89. },
  90. vote: '1',
  91. voteName: '续签',
  92. suggestion: '',
  93. other: ''
  94. },
  95. // 小区数据
  96. communityList: [],
  97. selectedCommunity: -1,
  98. // 楼栋数据
  99. buildingList: [],
  100. selectedBuilding: -1,
  101. // 房间号数据
  102. roomList: [],
  103. selectedRoom: -1,
  104. // 房产持有人信息
  105. name: '',
  106. idLastFour: '',
  107. phone: '',
  108. // 投票选项
  109. voteOptions: [{
  110. name: '续签',
  111. value: '1'
  112. },
  113. {
  114. name: '公开招标',
  115. value: '2'
  116. },
  117. {
  118. name: '弃权',
  119. value: '3'
  120. },
  121. {
  122. name: '其他',
  123. value: '4'
  124. }
  125. ],
  126. selectedVote: '1', // 默认选中公开招标
  127. // 建议
  128. suggestion: '',
  129. // 提交状态
  130. isLoading: false,
  131. rules: {
  132. 'communityId1': [{
  133. type: 'string',
  134. required: true,
  135. message: '请选择小区',
  136. trigger: ['blur', 'change']
  137. }],
  138. 'communityId2': [{
  139. type: 'string',
  140. required: true,
  141. message: '请选择楼栋号',
  142. trigger: ['blur', 'change']
  143. }],
  144. 'communityId3': [{
  145. type: 'string',
  146. required: true,
  147. message: '请选择房间号',
  148. trigger: ['blur', 'change']
  149. }],
  150. 'householder.name': [{
  151. type: 'string',
  152. required: true,
  153. message: '请输入姓名',
  154. trigger: ['blur', 'change']
  155. }],
  156. 'householder.cardNo': [{
  157. type: 'string',
  158. required: true,
  159. message: '请输入身份证号',
  160. trigger: ['blur', 'change']
  161. }, {
  162. required: true, // 是否必填(根据需求决定是否添加)
  163. pattern: /^[a-zA-Z0-9]{4}$/, // 正则:必须是4位数字(\d表示数字,{4}表示长度为4)
  164. message: '请输入4位数字', // 验证失败提示
  165. trigger: ['blur', 'change'] // 触发验证的时机(失去焦点/值改变)
  166. }],
  167. 'vote': [{
  168. type: 'string',
  169. required: true,
  170. message: '请选择投票项',
  171. trigger: ['blur', 'change']
  172. }],
  173. }
  174. };
  175. },
  176. onLoad() {
  177. this.getList(0, 'communityList')
  178. },
  179. methods: {
  180. handleInput1(val) {
  181. // 正则 /\s+/g 匹配所有空白字符(空格、换行等),替换为空
  182. this.inputForm.householder.name = val.replace(/\s+/g, '');
  183. },
  184. // 小区选择变化
  185. change1(e) {
  186. this.inputForm.communityName1=e.text
  187. this.inputForm.communityId2 = ''
  188. this.inputForm.communityId3 = ''
  189. this.buildingList = []
  190. this.roomList = []
  191. this.getList(e.value, "buildingList")
  192. },
  193. // 楼栋选择变化
  194. change2(e) {
  195. this.inputForm.communityId3 = ''
  196. this.roomList = []
  197. this.getList(e.value, "roomList")
  198. },
  199. // 投票选项变化
  200. onVoteChange(value) {
  201. this.selectedVote = value;
  202. },
  203. groupChange(e) {
  204. this.inputForm.vote = this.getValueByName(e)
  205. },
  206. getValueByName(targetName) {
  207. // 找到name匹配的选项对象
  208. const matchedOption = this.voteOptions.find(option => option.name === targetName);
  209. // 若找到则返回value,未找到返回null(或根据需求自定义默认值)
  210. return matchedOption ? matchedOption.value : null;
  211. },
  212. getList(parent_id, name) {
  213. communityService.getListById(parent_id).then((data) => {
  214. this[name] = data
  215. }).catch(e => {
  216. console.error(e)
  217. })
  218. },
  219. // 提交表单
  220. submitForm() {
  221. var _this = this
  222. if (this.inputForm.vote === '4' && !this.inputForm.other) {
  223. uni.showToast({
  224. title: '请填写您所满意的物业',
  225. icon: 'none',
  226. duration: 2000
  227. })
  228. return
  229. }
  230. this.$refs.uForm.validate().then(res => {
  231. uni.showLoading({
  232. title: '提交中',
  233. mask: true
  234. })
  235. _this.inputForm.householderName=_this.inputForm.householder.name
  236. voteRecordService.save(_this.inputForm).then((data) => {
  237. console.log(data)
  238. uni.hideLoading()
  239. uni.showToast({
  240. title: `提交成功`,
  241. icon: 'none',
  242. duration: 2000
  243. })
  244. setTimeout(() => {
  245. uni.reLaunch({
  246. url: '/pages/success?id='+_this.inputForm.communityId1
  247. });
  248. }, 2000);
  249. }).catch(e => {
  250. console.error(e)
  251. uni.hideLoading()
  252. uni.showModal({
  253. title: '提示',
  254. content: e.data.msg,
  255. showCancel:false
  256. })
  257. })
  258. }).catch(errors => {
  259. uni.$u.toast(errors[0].message)
  260. })
  261. },
  262. // 重置表单
  263. resetForm() {
  264. this.selectedCommunity = -1;
  265. this.selectedBuilding = -1;
  266. this.selectedRoom = -1;
  267. this.name = '';
  268. this.idLastFour = '';
  269. this.phone = '';
  270. this.selectedVote = 'bid';
  271. this.suggestion = '';
  272. }
  273. }
  274. };
  275. </script>
  276. <style scoped>
  277. .container {
  278. flex: 1;
  279. background-color: #ffffff;
  280. min-height: 100vh;
  281. font-family: "黑体";
  282. }
  283. /* 顶部标题栏 */
  284. .header {
  285. background-color: #00aaff;
  286. padding: 25rpx 20rpx;
  287. text-align: center;
  288. }
  289. .header-title {
  290. color: #ffffff;
  291. font-size: 32rpx;
  292. font-weight: 500;
  293. line-height: 1.5;
  294. }
  295. /* 内容区域 */
  296. .content {
  297. flex: 1;
  298. padding-bottom: 50rpx;
  299. }
  300. /* 分割线区域 */
  301. .section-divider {
  302. display: flex;
  303. align-items: center;
  304. padding: 20rpx 30rpx;
  305. background-color: #f5f7fa;
  306. margin: 10rpx 0;
  307. }
  308. .divider-text {
  309. color: #00aaff;
  310. font-size: 30rpx;
  311. font-weight: 500;
  312. }
  313. .divider-tag {
  314. color: #666666;
  315. font-size: 24rpx;
  316. margin-left: 15rpx;
  317. }
  318. /* 投票选项 */
  319. .vote-options {
  320. padding: 10rpx 30rpx;
  321. }
  322. .radio-item {
  323. display: flex;
  324. align-items: center;
  325. margin-bottom: 25rpx;
  326. font-size: 28rpx;
  327. color: #333333;
  328. }
  329. /* 建议区域 */
  330. .suggestion-section {
  331. padding: 20rpx 30rpx;
  332. }
  333. .suggestion-label {
  334. display: block;
  335. font-size: 32rpx;
  336. color: #333333;
  337. margin-bottom: 20rpx;
  338. }
  339. .suggestion-input {
  340. width: 100%;
  341. min-height: 200rpx;
  342. font-size: 26rpx;
  343. }
  344. /* 提交按钮 */
  345. .submit-btn-container {
  346. padding: 30rpx 20rpx;
  347. }
  348. .submit-btn {
  349. width: 100%;
  350. height: 90rpx;
  351. line-height: 90rpx;
  352. font-size: 32rpx;
  353. background-color: #00aaff;
  354. color: #ffffff;
  355. }
  356. /* uView组件样式调整 */
  357. ::v-deep .u-form-item__label {
  358. width: 160rpx !important;
  359. font-size: 28rpx !important;
  360. color: #333333 !important;
  361. }
  362. ::v-deep .u-input__inner {
  363. font-size: 28rpx !important;
  364. }
  365. ::v-deep .u-picker__placeholder {
  366. font-size: 28rpx !important;
  367. }
  368. ::v-deep .uni-select {
  369. border: unset;
  370. border-bottom: unset;
  371. }
  372. ::v-deep .uni-select__input-placeholder {
  373. color: rgb(192, 196, 204);
  374. font-size: 15px;
  375. }
  376. ::v-deep .u-form-item__body__left__content__label{
  377. font-size: 17px;
  378. }
  379. ::v-deep .uni-input-input{
  380. font-size: 18px;
  381. }
  382. ::v-deep .uni-select__input-text{
  383. font-size: 18px;
  384. }
  385. </style>