property-select.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="box">
  3. <view class="input-box">
  4. <view class="input-box-left" :style="{'letter-spacing':labelWidth}">
  5. {{ label }}
  6. </view>
  7. <view class="input-box-right input-box-text" @click="showUploadingImg(true)">
  8. <text :class="{'no-option':!optionName}">{{ optionName ? optionName : placeholder }}</text>
  9. </view>
  10. <view class="input-box-right" @click="showUploadingImg(true)">
  11. <text class="iconfont">&#xe62b;</text>
  12. </view>
  13. </view>
  14. <uni-popup ref="popup" :safeArea="false" type="bottom" @change="closePopup">
  15. <view class="popup-block">
  16. <view class="popup-title">
  17. <view class="popup-title-text">选择资产</view>
  18. <view class="title-del" @click="showUploadingImg(false)">
  19. <image src="/pages-task/static/img/new-add/del-title.png"></image>
  20. </view>
  21. </view>
  22. <view class="add-row" @click.stop="setAddId(addItem.value)"
  23. :class="{'checked-row':inputValue.indexOf(addItem.value)>=0,'row-one':addItem.type===2,'row-two':addItem.type===3,'row-three':addItem.type===4}" 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={'value':item.property_sn,'type':propertyType}
  112. if(propertyType===1){
  113. propertyItem.text='房产信息('+typeOne+')'
  114. propertyItem.remark='房产地址:'+item.data.house_address
  115. ++typeOne;
  116. }else if(propertyType===2){
  117. propertyItem.text='车辆信息('+typeTwo+')'
  118. propertyItem.remark='车牌号:'+item.data.car_num
  119. ++typeTwo;
  120. }else if(propertyType===3){
  121. propertyItem.text='保单信息('+typeThree+')'
  122. propertyItem.remark='保险公司:'+item.data.insurance_name
  123. ++typeThree;
  124. }else {
  125. propertyItem.text='企业信息('+typeFour+')'
  126. propertyItem.remark='企业名称:'+item.data.firm_name
  127. ++typeFour;
  128. }
  129. this.localData.push(propertyItem)
  130. })
  131. this.setValue()
  132. },
  133. setAddId(id) {
  134. console.log('id:'+id)
  135. let key = this.inputValue.indexOf(id)
  136. if (key >= 0) {
  137. this.inputValue.splice(key, 1)
  138. } else {
  139. this.inputValue.push(id)
  140. }
  141. },
  142. showUploadingImg(showImg) {
  143. this.addItemIds = []
  144. if (showImg) {
  145. this.$refs.popup.open("bottom");
  146. } else {
  147. this.$refs.popup.close();
  148. this.isUploading = false
  149. }
  150. },
  151. setValue() {
  152. this.inputValue=this.value
  153. if (this.inputValue) {
  154. this.optionName = "";
  155. this.localData.forEach((one) => {
  156. if ( this.inputValue.indexOf(one.value)>=0) {
  157. if(this.optionName)this.optionName+=","
  158. this.optionName += one.text;
  159. }
  160. })
  161. }
  162. },
  163. setLabelWidth() {
  164. let differenceNum = 4 - this.label.length;
  165. if (differenceNum === 2) {
  166. this.labelWidth = '2em'
  167. } else if (differenceNum === 1) {
  168. this.labelWidth = '0.5em'
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. @import "@/components/static/css/en-common.css";
  176. .box {
  177. .input-box {
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. .input-box-left {
  182. width: 210rpx;
  183. font-size: 30rpx;
  184. color: #333333;
  185. }
  186. .input-box-right {
  187. width: 40rpx;
  188. text {
  189. font-size: 28rpx;
  190. color: #333;
  191. }
  192. .iconfont {
  193. float: right;
  194. }
  195. .no-option {
  196. color: #999999;
  197. }
  198. }
  199. .input-box-text{
  200. width: calc(100% - 250rpx);
  201. display: -webkit-box;
  202. -webkit-line-clamp: 1;
  203. -webkit-box-orient: vertical;
  204. overflow: hidden;
  205. }
  206. }
  207. .popup-block {
  208. border-radius: 20rpx 20rpx 0 0;
  209. background: #F6F7FB;
  210. padding: 0 0 calc(env(safe-area-inset-bottom) - 10rpx);
  211. max-height: 60vh;
  212. overflow-y: auto;
  213. .popup-title {
  214. background: #fff;
  215. border-bottom: 2rpx solid #F0F0F0;
  216. padding: 40rpx 0;
  217. position: relative;
  218. .popup-title-text {
  219. text-align: center;
  220. font-size: 34rpx;
  221. font-weight: 600;
  222. }
  223. .title-del {
  224. position: absolute;
  225. top: 40rpx;
  226. right: 40rpx;
  227. image {
  228. height: 40rpx;
  229. width: 40rpx;
  230. }
  231. }
  232. }
  233. .add-row {
  234. margin: 20rpx 32rpx 0;
  235. background: #F20303;
  236. border-radius: 10rpx;
  237. height: 144rpx;
  238. position: relative;
  239. .row-data {
  240. position: absolute;
  241. left: 4rpx;
  242. top: -1rpx;
  243. box-sizing: border-box;
  244. //padding: 36rpx 30rpx;
  245. width: 100%;
  246. height: 148rpx;
  247. display: flex;
  248. justify-content: space-between;
  249. background: #fff;
  250. border-radius: 10rpx;
  251. .row-item {
  252. color: #333333;
  253. font-size: 32rpx;
  254. }
  255. .row-item:last-child {
  256. display: none;
  257. }
  258. .row-content {
  259. padding: 36rpx 26rpx;
  260. .content-title{
  261. color: #333333;
  262. font-size: 32rpx;
  263. font-weight: 600;
  264. height: 45rpx;
  265. line-height: 45rpx;
  266. }
  267. .content-remark{
  268. margin-top: 24rpx;
  269. color: #999999;
  270. font-size: 24rpx;
  271. height: 39rpx;
  272. line-height: 39rpx;
  273. display: -webkit-box;
  274. -webkit-line-clamp: 1;
  275. -webkit-box-orient: vertical;
  276. overflow: hidden;
  277. }
  278. }
  279. }
  280. }
  281. .row-one{
  282. background: #219653;
  283. }
  284. .row-two{
  285. background: #FD8537;
  286. }
  287. .row-three{
  288. background: #3169FA;
  289. }
  290. .checked-row {
  291. .row-data{
  292. .row-item:last-child {
  293. margin-top: 35rpx;
  294. margin-right: 28rpx;
  295. display: block;
  296. .iconfont {
  297. color: #3169FA;
  298. font-size: 42rpx;
  299. }
  300. }
  301. }
  302. }
  303. .add-but {
  304. margin: 50rpx 32rpx 0;
  305. border-radius: 10rpx;
  306. padding: 36rpx 30rpx;
  307. font-size: 32rpx;
  308. color: #fff;
  309. text-align: center;
  310. background: #3169FA;
  311. }
  312. }
  313. }
  314. </style>