property-select.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="box">
  3. <view class="input-box row-justify-sb center">
  4. <view class="input-box-left" :style="{'letter-spacing':labelWidth}">
  5. {{ label }}
  6. </view>
  7. <view class="row-c" @click="showUploadingImg(true)">
  8. <text class="p-r10 size-28"
  9. :class="{'no-option':!optionName}">{{ optionName ? optionName : placeholder }}</text>
  10. <uni-icons type="forward" size="18" color="#D8D8D8"></uni-icons>
  11. </view>
  12. </view>
  13. <uni-popup ref="popup" :safeArea="false" type="bottom" @change="closePopup">
  14. <view class="popup-block">
  15. <view class="popup-title">
  16. <view class="popup-title-text">选择资产</view>
  17. <view class="title-del" @click="showUploadingImg(false)">
  18. <image src="/page_task/static/img/information/del-title.png"></image>
  19. </view>
  20. </view>
  21. <view class="add-row" @click.stop="setAddId(addItem.value)"
  22. :class="{'checked-row':inputValue.indexOf(addItem.value)>=0,'row-one':addItem.type===2,'row-two':addItem.type===3,'row-three':addItem.type===4}"
  23. v-for="addItem in localData">
  24. <view class="row-data">
  25. <view class="row-item row-content">
  26. <view class="content-title">{{addItem.text}}</view>
  27. <view class="content-remark">{{addItem.remark}}</view>
  28. </view>
  29. <view class="row-item">
  30. <text class="iconfont">
  31. &#xe621;
  32. </text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="add-but" @click.stop="showUploadingImg(false)">确定</view>
  37. </view>
  38. </uni-popup>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. name: 'property-select',
  44. props: {
  45. 'propertyList': {
  46. default: []
  47. },
  48. label: {
  49. type: String,
  50. default: '标题'
  51. },
  52. placeholder: {
  53. type: String,
  54. default: '请选择'
  55. },
  56. disabled: {
  57. type: Boolean,
  58. default: false
  59. },
  60. name: {
  61. type: String,
  62. default: 'text'
  63. },
  64. valueType: {
  65. type: String,
  66. default: '1'
  67. },
  68. value: {
  69. default: ''
  70. }
  71. },
  72. data() {
  73. return {
  74. addList: [],
  75. inputValue: [],
  76. localData: [],
  77. optionName: '',
  78. labelWidth: 0,
  79. showPicker: false
  80. }
  81. },
  82. components: {},
  83. mounted() {
  84. this.setLocalData()
  85. this.setLabelWidth()
  86. },
  87. watch: {
  88. 'value': function() {
  89. this.setValue()
  90. },
  91. 'inputValue': function() {
  92. this.$emit('input', this.inputValue)
  93. this.setValue()
  94. },
  95. 'propertyList': function() {
  96. this.setLocalData()
  97. }
  98. },
  99. methods: {
  100. closePopup(e) {
  101. },
  102. setLocalData() {
  103. // 设置资产选择列表
  104. this.localData = [];
  105. let typeOne = 1;
  106. let typeTwo = 1;
  107. let typeThree = 1;
  108. let typeFour = 1;
  109. this.propertyList.forEach((item) => {
  110. let propertyType = item.property_type * 1;
  111. let propertyItem = {
  112. 'value': item.property_sn,
  113. 'type': propertyType
  114. }
  115. if (propertyType === 1) {
  116. propertyItem.text = '房产信息(' + typeOne + ')'
  117. propertyItem.remark = '房产地址:' + item.data.house_address
  118. ++typeOne;
  119. } else if (propertyType === 2) {
  120. propertyItem.text = '车辆信息(' + typeTwo + ')'
  121. propertyItem.remark = '车牌号:' + item.data.car_num
  122. ++typeTwo;
  123. } else if (propertyType === 3) {
  124. propertyItem.text = '保单信息(' + typeThree + ')'
  125. propertyItem.remark = '保险公司:' + item.data.insurance_name
  126. ++typeThree;
  127. } else {
  128. propertyItem.text = '企业信息(' + typeFour + ')'
  129. propertyItem.remark = '企业名称:' + item.data.firm_name
  130. ++typeFour;
  131. }
  132. this.localData.push(propertyItem)
  133. })
  134. this.setValue()
  135. },
  136. setAddId(id) {
  137. console.log('id:' + id)
  138. let key = this.inputValue.indexOf(id)
  139. if (key >= 0) {
  140. this.inputValue.splice(key, 1)
  141. } else {
  142. this.inputValue.push(id)
  143. }
  144. },
  145. showUploadingImg(showImg) {
  146. this.addItemIds = []
  147. if (showImg) {
  148. this.$refs.popup.open("bottom");
  149. } else {
  150. this.$refs.popup.close();
  151. this.isUploading = false
  152. }
  153. },
  154. setValue() {
  155. this.inputValue = this.value
  156. if (this.inputValue) {
  157. this.optionName = "";
  158. this.localData.forEach((one) => {
  159. if (this.inputValue.indexOf(one.value) >= 0) {
  160. if (this.optionName) this.optionName += ","
  161. this.optionName += one.text;
  162. }
  163. })
  164. }
  165. },
  166. setLabelWidth() {
  167. let differenceNum = 4 - this.label.length;
  168. if (differenceNum === 2) {
  169. this.labelWidth = '2em'
  170. } else if (differenceNum === 1) {
  171. this.labelWidth = '0.5em'
  172. }
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. @import "@/components/static/css/en-common.css";
  179. .box {
  180. .input-box {
  181. display: flex;
  182. align-items: center;
  183. justify-content: space-between;
  184. .input-box-left {
  185. font-size: 28rpx;
  186. color: #333333;
  187. }
  188. .no-option {
  189. color: #999999;
  190. }
  191. .input-box-text {
  192. display: -webkit-box;
  193. -webkit-line-clamp: 1;
  194. -webkit-box-orient: vertical;
  195. overflow: hidden;
  196. }
  197. }
  198. .popup-block {
  199. border-radius: 20rpx 20rpx 0 0;
  200. background: #F6F7FB;
  201. padding: 0 0 calc(env(safe-area-inset-bottom) - 10rpx);
  202. max-height: 60vh;
  203. overflow-y: auto;
  204. .popup-title {
  205. background: #fff;
  206. border-bottom: 2rpx solid #F0F0F0;
  207. padding: 40rpx 0;
  208. position: relative;
  209. .popup-title-text {
  210. text-align: center;
  211. font-size: 34rpx;
  212. font-weight: 600;
  213. }
  214. .title-del {
  215. position: absolute;
  216. top: 40rpx;
  217. right: 40rpx;
  218. image {
  219. height: 40rpx;
  220. width: 40rpx;
  221. }
  222. }
  223. }
  224. .add-row {
  225. margin: 20rpx 32rpx 0;
  226. background: #F20303;
  227. border-radius: 10rpx;
  228. height: 144rpx;
  229. position: relative;
  230. .row-data {
  231. position: absolute;
  232. left: 4rpx;
  233. top: -1rpx;
  234. box-sizing: border-box;
  235. //padding: 36rpx 30rpx;
  236. width: 100%;
  237. height: 148rpx;
  238. display: flex;
  239. justify-content: space-between;
  240. background: #fff;
  241. border-radius: 10rpx;
  242. .row-item {
  243. color: #333333;
  244. font-size: 32rpx;
  245. }
  246. .row-item:last-child {
  247. display: none;
  248. }
  249. .row-content {
  250. padding: 36rpx 26rpx;
  251. .content-title {
  252. color: #333333;
  253. font-size: 32rpx;
  254. font-weight: 600;
  255. height: 45rpx;
  256. line-height: 45rpx;
  257. }
  258. .content-remark {
  259. margin-top: 24rpx;
  260. color: #999999;
  261. font-size: 24rpx;
  262. height: 39rpx;
  263. line-height: 39rpx;
  264. display: -webkit-box;
  265. -webkit-line-clamp: 1;
  266. -webkit-box-orient: vertical;
  267. overflow: hidden;
  268. }
  269. }
  270. }
  271. }
  272. .row-one {
  273. background: #219653;
  274. }
  275. .row-two {
  276. background: #FD8537;
  277. }
  278. .row-three {
  279. background:#219653;
  280. }
  281. .checked-row {
  282. .row-data {
  283. .row-item:last-child {
  284. margin-top: 35rpx;
  285. margin-right: 28rpx;
  286. display: block;
  287. .iconfont {
  288. color: #219653;
  289. font-size: 42rpx;
  290. }
  291. }
  292. }
  293. }
  294. .add-but {
  295. margin: 50rpx 32rpx 0;
  296. border-radius: 10rpx;
  297. padding: 36rpx 30rpx;
  298. font-size: 32rpx;
  299. color: #fff;
  300. text-align: center;
  301. background: #219653;
  302. }
  303. }
  304. }
  305. </style>