detail.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <ComponentLoading class="d_w" :loading="loading">
  3. <!-- <WindowTop :title="title"></WindowTop> -->
  4. <view class="card">
  5. <view class="form_item">
  6. <view class="label">姓名</view>
  7. <input v-model="form.xm" placeholder="请输入姓名" v-if="type == 'add'" />
  8. <view class="value" v-else>{{ form.xm || '' }}</view>
  9. </view>
  10. <view class="form_item">
  11. <view class="label">身份证号</view>
  12. <input v-model="form.sfzh" placeholder="请输入身份证号" v-if="type == 'add'" />
  13. <view class="value" v-else>{{ form.sfzh || '' }}</view>
  14. </view>
  15. <view class="form_item">
  16. <view class="label">联系方式</view>
  17. <input v-model="form.lxfs" placeholder="请输入联系方式" v-if="type == 'add'" />
  18. <view class="value" v-else>{{ form.lxfs || '' }}</view>
  19. </view>
  20. <view class="form_item">
  21. <view class="label">政治面貌</view>
  22. <picker @change="zzmmChange" :value="zzmmIndex" :range="zzmmOp" range-key="label" v-if="type == 'add'">
  23. <view class="uni-input">{{ zzmmOp[zzmmIndex]['label'] || '' }}</view>
  24. </picker>
  25. <view class="value" v-else>{{ zzmmView || '' }}</view>
  26. </view>
  27. <view class="form_item">
  28. <view class="label">三长类别</view>
  29. <picker @change="szlbChange" :value="szlbIndex" :range="szlbOp" v-if="type == 'add'">
  30. <view class="uni-input">{{ szlbOp[szlbIndex] }}</view>
  31. </picker>
  32. <view class="value" v-else>{{ form.szlb || '' }}</view>
  33. </view>
  34. <view class="form_item">
  35. <view class="label">单位职务</view>
  36. <input v-model="form.dwzw" placeholder="请输入单位职务" v-if="type == 'add'" />
  37. <view class="value" v-else>{{ form.dwzw }}</view>
  38. </view>
  39. <view class="form_item text_area" style="height: 400rpx;">
  40. <view class="label">居住地址</view>
  41. <textarea v-model="form.zz" placeholder="请输入居住地址" v-if="type == 'add'" />
  42. <view class="value" v-else>{{ form.zz }}</view>
  43. </view>
  44. </view>
  45. <view class="f_b" @click="save" v-if="type == 'add'">
  46. <view>提 交</view>
  47. </view>
  48. </ComponentLoading>
  49. </template>
  50. <script>
  51. import {
  52. saveXxy,
  53. detail,
  54. dictionary
  55. } from '@/api/wjxxy.js'
  56. import WindowTop from '@/components/window-top/index'
  57. import ComponentLoading from '@/components/component-loading/index'
  58. export default {
  59. components: {
  60. WindowTop,
  61. ComponentLoading
  62. },
  63. data() {
  64. return {
  65. type: 'add',
  66. form: {
  67. xm: '',
  68. sfzh: '',
  69. lxfs: '',
  70. ldId: '',
  71. dyh: '',
  72. zzmm: '01',
  73. szlb: '网格长',
  74. dwzw: '',
  75. zz: ''
  76. },
  77. loading: false,
  78. zzmmOp: [],
  79. zzmmIndex: 0,
  80. szlbOp: ['网格长', '单元长', '楼栋长'],
  81. szlbIndex: 0,
  82. zzmmView: ''
  83. }
  84. },
  85. computed: {
  86. title() {
  87. if (this.type == 'add') {
  88. return '添加物建员'
  89. } else {
  90. return '物建员详情'
  91. }
  92. }
  93. },
  94. onLoad(option) {
  95. this.type = option.type
  96. if (this.type == 'add') {
  97. this.form.ldId = option.ldId
  98. this.form.dyh = option.dyh
  99. let p = this.getOp()
  100. this.loading = true
  101. p.finally(() => {
  102. this.loading = false
  103. })
  104. } else {
  105. this.loading = true
  106. let p1 = this.getDetail(option.id)
  107. let p2 = this.getOp()
  108. Promise.all([p1, p2]).then(res => {
  109. const list = this.zzmmOp
  110. for (let i = 0; i < list.length; i++) {
  111. if (list[i].value == this.form.zzmm) {
  112. this.zzmmView = list[i].label
  113. }
  114. }
  115. }).finally(() => {
  116. this.loading = false
  117. })
  118. }
  119. },
  120. methods: {
  121. getDetail(id) {
  122. let p = new Promise((resolute, reject) => {
  123. detail(id.toString()).then(res => {
  124. let data = JSON.parse(res.data.dataList[0].fieldValues[0].value).data
  125. if (data) {
  126. this.form = data
  127. }
  128. resolute()
  129. }).catch(() => {
  130. reject()
  131. })
  132. })
  133. return p
  134. },
  135. getOp() {
  136. let p = new Promise((resolute, reject) => {
  137. dictionary().then(res => {
  138. this.zzmmOp = JSON.parse(res.data.dataList[0].fieldValues[0].value).data.zzmm
  139. resolute()
  140. }).catch(() => {
  141. reject()
  142. })
  143. })
  144. return p
  145. },
  146. zzmmChange(e) {
  147. const index = e.detail.value
  148. this.zzmmIndex = index
  149. this.form.zzmm = this.zzmmOp[index]['value']
  150. },
  151. szlbChange(e) {
  152. const index = e.detail.value
  153. this.szlbIndex = index
  154. this.form.szlb = this.szlbOp[index]
  155. },
  156. save() {
  157. this.loading = true
  158. saveXxy(this.form).then(res => {
  159. uni.navigateBack();
  160. }).finally(() => {
  161. this.loading = false
  162. })
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .d_w {
  169. height: 100vh;
  170. display: flex;
  171. flex-direction: column;
  172. }
  173. .card {
  174. box-shadow: 0rpx 2rpx 16rpx 0rpx rgba(0, 0, 0, 0.08);
  175. border-radius: 16rpx;
  176. padding: 0 24rpx;
  177. flex: 1;
  178. margin: 8rpx 24rpx;
  179. }
  180. .form_item {
  181. border-bottom: 1rpx solid rgba(231, 231, 231, 1);
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. height: 100rpx;
  186. uni-input {
  187. width: 50vw;
  188. }
  189. uni-picker {
  190. width: 50vw;
  191. }
  192. textarea {
  193. width: 50vw;
  194. }
  195. }
  196. .text_area {
  197. align-items: flex-start !important;
  198. // border: 1rpx solid rgba(231, 231, 231, 1);
  199. .label {
  200. margin-top: 16rpx;
  201. }
  202. }
  203. .f_b {
  204. background-color: rgba(16, 109, 255, 1);
  205. border-radius: 16rpx;
  206. // width: 100%;
  207. width: calc(100% - 48rpx);
  208. height: 88rpx;
  209. margin: 24rpx;
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. color: rgba(255, 255, 255, 1);
  214. font-size: 36rpx;
  215. font-weight: 600;
  216. }
  217. </style>