car.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="">
  3. <view class="data-from" v-for="(item,index) in carList">
  4. <view class="p-t30" v-if="editIndex!==index">
  5. <view class="sys-from-background-color p-20 r-20">
  6. <view class="row-justify-sb center">
  7. <text class="size-28 sys-weight-600">车辆信息({{index+1}})</text>
  8. <view class="row-c sys-background-fff r-100 p-lr40 p-tb10">
  9. <image class="wh-30"
  10. src="/page_task/static/img/information/edit.png"
  11. mode="aspectFill" @click="onEditInfo(index)"></image>
  12. <view class="title-line m-lr20"></view>
  13. <image class="wh-30"
  14. src="/page_task/static/img/information/delete.png"
  15. mode="aspectFill" @click="onDeleteInfo(index)">
  16. </image>
  17. </view>
  18. </view>
  19. <view class="row p-t30" v-if="verifyKey('brand_id')">
  20. <view class="text-color-666"><text></text>车辆品牌:</view>
  21. <text class="flex">{{getTypeText(item.data.brand_id,1)}}</text>
  22. </view>
  23. <view class="row p-t30" v-if="verifyKey('car_type')">
  24. <view class="text-color-666"><text></text>车牌类型:</view>
  25. <text class="flex">{{getTypeText(item.data.car_type,2)}}</text>
  26. </view>
  27. <view class="row p-t30" v-if="verifyKey('car_num')">
  28. <view class="text-color-666"><text></text>车牌号:</view>
  29. <text class="flex">{{item.data.car_num}}</text>
  30. </view>
  31. <view class="row p-t30" v-if="verifyKey('car_vin')">
  32. <view class="text-color-666"><text></text>车架号:</view>
  33. <text class="flex">{{item.data.car_vin}}</text>
  34. </view>
  35. <view class="row p-t30" v-if="verifyKey('colour')">
  36. <view class="text-color-666"><text></text>车辆颜色:</view>
  37. <text class="flex">{{item.data.colour}}</text>
  38. </view>
  39. <view class="row p-t30" v-if="verifyKey('car_price')">
  40. <view class="text-color-666"><text></text>裸车价格:</view>
  41. <text class="flex">{{item.data.car_price}}</text>
  42. </view>
  43. <view class="row p-t30" v-if="verifyKey('register_date')">
  44. <view class="text-color-666"><text></text>登记时间:</view>
  45. <text class="flex">{{item.data.register_date}}</text>
  46. </view>
  47. <view class="row p-t30" v-if="verifyKey('register_img')">
  48. <view class="text-color-666"><text></text>登记证书:</view>
  49. <EnImage :img="item.data.register_img"></EnImage>
  50. </view>
  51. <view class="row p-t30" v-if="verifyKey('driving_img')">
  52. <view class="text-color-666"><text></text>行驶证:</view>
  53. <EnImage :img="item.data.driving_img"></EnImage>
  54. </view>
  55. <view class="row p-t30" v-if="verifyKey('car_img')">
  56. <view class="text-color-666"><text></text>辆相关图片:</view>
  57. <EnImage :img="item.data.car_img"></EnImage>
  58. </view>
  59. <view class="row p-t30">
  60. <view class="text-color-666"><text></text>备注:</view>
  61. <text class="flex">{{item.data.remark}}</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="p-t30" v-else>
  66. <view class="row-justify-sb center p-b10">
  67. <text class="size-28 sys-weight-600">房产信息({{index+1}})</text>
  68. <view class="row-c sys-background-fff r-100">
  69. <image class="wh-30"
  70. src="/page_task/static/img/information/delete.png"
  71. mode="aspectFill" @click="onDeleteInfo(index)">
  72. </image>
  73. </view>
  74. </view>
  75. <en-input label="车辆品牌" type="text" placeholder="请输入车辆品牌" v-model="item.data.brand_id"
  76. v-if="verifyKey('brand_id')"></en-input>
  77. <en-radio label="车牌类型" :radio-data="carTypeData" v-model="item.data.car_type"
  78. v-if="verifyKey('car_type')"></en-radio>
  79. <en-input label="车牌号" type="text" placeholder="请输入车牌号" v-model="item.data.car_num"
  80. v-if="verifyKey('car_num')"></en-input>
  81. <en-input label="车架号" type="text" placeholder="请输入车架号" v-model="item.data.car_vin"
  82. v-if="verifyKey('car_vin')"></en-input>
  83. <en-input label="车辆颜色" type="text" placeholder="请输入车俩颜色" v-model="item.data.colour"
  84. v-if="verifyKey('colour')"></en-input>
  85. <en-input label="裸车价格" type="number" placeholder="请输入金额" v-model="item.data.car_price"
  86. v-if="verifyKey('car_price')" rightText="元"></en-input>
  87. <en-date label="登记时间" placeholder="选择车辆登记时间" v-model="item.data.register_date"
  88. v-if="verifyKey('register_date')"></en-date>
  89. <add-register img-type="2" v-model="item.data.register_img" @setCarData="setCarData"
  90. v-if="verifyKey('register_img')"></add-register>
  91. <add-register v-model="item.data.driving_img" @setCarData="setCarData"
  92. v-if="verifyKey('driving_img')"></add-register>
  93. <en-upload label="上传车辆相关图片" :imageWidth="180" v-model="item.data.car_img"
  94. v-if="verifyKey('car_img')"></en-upload>
  95. <en-input label="备注" type="text" placeholder="请输入备注信息" v-model="item.data.remark" v-if="verifyKey('remark')"
  96. :noBox="true"></en-input>
  97. </view>
  98. </view>
  99. <en-blank message="暂无车辆信息,快来添加吧!" v-if="carList.length<=0"></en-blank>
  100. <button class="size-26 r-10 button-color house-button m-t30" hover-class="is-hover"
  101. @click="addItem">+添加车辆</button>
  102. </view>
  103. </template>
  104. <script>
  105. import enInput from "@/components/en-from/en-input/en-input.vue"
  106. import EnCity from "@/components/en-from/en-city/en-city.vue";
  107. import EnUpload from "@/components/en-from/en-upload/en-upload.vue";
  108. import EnSelect from "@/components/en-from/en-select/en-select.vue";
  109. import {
  110. getTaskOptions
  111. } from "@/api/task";
  112. import md5 from "js-md5";
  113. import EnDate from "@/components/en-from/en-date/en-date.vue";
  114. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  115. import AddRegister from "@/page_task/property/components/add-register.vue";
  116. import tools from "@/service/tools";
  117. import {
  118. getSn
  119. } from "@/api/common";
  120. import EnImage from "@/components/en-utils/en-image/en-image.vue";
  121. export default {
  122. name: 'property-car',
  123. components: {
  124. EnImage,
  125. AddRegister,
  126. EnBlank,
  127. EnDate,
  128. EnSelect,
  129. EnUpload,
  130. EnCity,
  131. enInput
  132. },
  133. props: {
  134. 'showKeys': {
  135. default: []
  136. },
  137. 'value': {
  138. default: {
  139. }
  140. },
  141. 'itemKey': {
  142. default: 0
  143. }
  144. },
  145. data() {
  146. return {
  147. editIndex:0,
  148. carTypeData: [{
  149. 'id': 1,
  150. 'name': '运营车'
  151. }, {
  152. 'id': 2,
  153. 'name': '非运营车'
  154. }],
  155. carBrandData: [],
  156. carItem: {
  157. 'car_type': '2',
  158. 'brand_id': '',
  159. 'car_num': '',
  160. 'car_vin': '',
  161. 'colour': '',
  162. 'car_price': '',
  163. 'register_date': '',
  164. 'register_img': '',
  165. 'driving_img': '',
  166. 'car_img': [],
  167. 'remark': '',
  168. },
  169. carList: []
  170. }
  171. },
  172. watch: {
  173. 'carList': {
  174. handler() {
  175. this.$emit("input", this.carList);
  176. },
  177. deep: true
  178. },
  179. 'value': {
  180. handler() {
  181. if (this.value) {
  182. this.setValue()
  183. }
  184. },
  185. deep: true
  186. },
  187. },
  188. mounted() {
  189. this.getTaskOptions()
  190. this.setValue()
  191. },
  192. methods: {
  193. getTypeText(val){
  194. val=val*1
  195. for (const typeKey in this.houseTypeData) {
  196. if(val===this.houseTypeData[typeKey].value){
  197. return this.houseTypeData[typeKey].text
  198. }
  199. }
  200. },
  201. onDeleteInfo(itemKey) {
  202. uni.showModal({
  203. title: '是否删除当前资产信息',
  204. content: '确定删除?',
  205. success: (res) => {
  206. if (res.confirm) {
  207. this.carList.splice(itemKey, 1)
  208. this.editIndex = itemKey-1
  209. }
  210. }
  211. })
  212. },
  213. onEditInfo(index){
  214. this.editIndex = index
  215. },
  216. setCarData(carData) {
  217. console.log('carData')
  218. console.log(this.carData)
  219. // if(carData.car_num){
  220. // this.caritem.data.car_num=carData.car_num
  221. // }
  222. // if(carData.car_vin){
  223. // this.carItem.car_vin=carData.car_vin
  224. // }
  225. // if(carData.colour){
  226. // this.carItem.colour=carData.colour
  227. // }
  228. // if(carData.register_date){
  229. // this.carItem.register_date=carData.register_date
  230. // }
  231. // if(carData.car_type){
  232. // this.carItem.car_type=carData.car_type
  233. // }
  234. // if(carData.brand_id){
  235. // this.carItem.brand_id=carData.brand_id
  236. // }
  237. },
  238. addItem() {
  239. tools.showLoading()
  240. getSn().then((res) => {
  241. if (res.code === 1) {
  242. this.carList.push({
  243. 'property_type': 2,
  244. 'property_sn': res.data,
  245. 'data': JSON.parse(JSON.stringify(this.carItem))
  246. })
  247. this.editIndex = this.carList.length-1
  248. this.$emit('onResize')
  249. } else {
  250. tools.error('编号生成失败')
  251. }
  252. tools.hideLoading()
  253. })
  254. },
  255. setSendMd5() {
  256. let str = JSON.stringify(this.value)
  257. this.sendMd5 = md5(JSON.stringify(this.carList))
  258. return md5(str)
  259. },
  260. setValue() {
  261. if (this.value) {
  262. let sendMd5 = this.setSendMd5()
  263. if (sendMd5 !== this.sendMd5) {
  264. this.carList = this.value
  265. }
  266. }
  267. },
  268. verifyKey(field) {
  269. return this.showKeys.indexOf(field) >= 0
  270. },
  271. async getTaskOptions() {
  272. const res = await getTaskOptions({
  273. 'type': 2
  274. })
  275. if (res.code === 1) {
  276. res.data.carBrand.forEach((val) => {
  277. this.carBrandData.push({
  278. 'text': val.name,
  279. 'value': val.value
  280. })
  281. })
  282. }
  283. },
  284. delItem() {
  285. uni.showModal({
  286. title: '警告',
  287. content: '是否删除当前车辆信息!',
  288. success: (res) => {
  289. if (res.confirm) {
  290. this.$emit('delItem', this.itemKey)
  291. }
  292. }
  293. });
  294. }
  295. }
  296. }
  297. </script>
  298. <style>
  299. .house-button {
  300. height: 70rpx;
  301. line-height: 70rpx;
  302. background: #FFFFFF;
  303. border: 1rpx solid #0FB160;
  304. }
  305. </style>