环卫车小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
7.7 KiB

1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
1 year ago
  1. <template>
  2. <view class="se-m-20 se-p-20 se-br-10">
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <u-form-item labelWidth="0">
  5. <view class="se-fs-26 se-c-black se-pb-10">
  6. 请选择您要寻找的车辆类型
  7. </view>
  8. <view class="se-flex se-flex-ai-c se-flex-ff-rw">
  9. <view v-if="item.name !='环卫设备及配件'" class="se-py-10 se-px-30 se-fs-22 se-br-10 se-mr-15 se-mt-10" :class="item.id==form.cartypeId ? 'se-bgc-green se-c-white se-b-green' : 'se-b se-c-text'" @click="handleCartype(item)" v-for="(item,index) in categoryList" :key="index">
  10. {{item.name}}
  11. </view>
  12. </view>
  13. </u-form-item>
  14. <u-form-item label="类型" prop="categorytwoId" @click="showType=true">
  15. <u--input border="bottom" v-model="form.categorytwoName" disabled placeholder="请填写类型"></u--input>
  16. <u-icon slot="right" name="arrow-right"></u-icon>
  17. </u-form-item>
  18. <u-form-item label="车辆型号" prop="model">
  19. <u--input v-model="form.model" placeholder="请填写车辆型号"></u--input>
  20. </u-form-item>
  21. <template v-if="form.cartypeName!='新车'">
  22. <u-form-item label="年限" prop="date" @click="showDate=true" >
  23. <u--input border="bottom" v-model="form.date" disabled placeholder="请填写年限"></u--input>
  24. <u-icon slot="right" name="arrow-right"></u-icon>
  25. </u-form-item>
  26. </template>
  27. <u-form-item label="公里数" prop="distance">
  28. <u--input v-model="form.distance" placeholder="请填写公里数"></u--input>
  29. </u-form-item>
  30. <u-form-item label="联系人" prop="contacts">
  31. <u--input v-model="form.contacts" placeholder="请填写联系人"></u--input>
  32. </u-form-item>
  33. <u-form-item label="联系电话" prop="phone">
  34. <u--input v-model="form.phone" placeholder="请填写联系电话"></u--input>
  35. </u-form-item>
  36. <u-form-item label="备注" labelPosition="top" prop="remark">
  37. <u--textarea class="se-mt-20" v-model="form.remark" count
  38. placeholder="请填写备注"></u--textarea>
  39. </u-form-item>
  40. <u-form-item>
  41. <view class="se-px-20 se-pt-20">
  42. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  43. <view @click="onSubmit"
  44. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-green">
  45. <text>确认申请</text>
  46. </view>
  47. </view>
  48. </view>
  49. </u-form-item>
  50. </u--form>
  51. <u-action-sheet
  52. :show="showType"
  53. :actions="categoryTwoList"
  54. title="请选择类型"
  55. @close="showType = false"
  56. @select="categoryTwoSelect"
  57. >
  58. </u-action-sheet>
  59. <u-picker :show="showDate" :columns="columns" @confirm="onConfirm"
  60. @cancel="onCancel"></u-picker>
  61. <!-- <u-datetime-picker
  62. :maxDate="maxDate"
  63. :show="showDate"
  64. v-model="date"
  65. mode="date"
  66. @confirm="onConfirm"
  67. @cancel="onCancel"
  68. ></u-datetime-picker> -->
  69. </view>
  70. </template>
  71. <script>
  72. const now = new Date();
  73. const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
  74. const startOfYesterday = startOfToday - 24 * 60 * 60 * 1000;
  75. import { queryTypeList,addApply,queryCategoryList } from "@/common/api.js"
  76. export default {
  77. components:{
  78. },
  79. data() {
  80. return {
  81. columns:[['2025', '2024', '2023', '2022', '2020', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000']],
  82. maxDate:startOfYesterday,
  83. categoryTwoList:[],
  84. categoryList:[],
  85. showDate:false,
  86. showType:false,
  87. actions: [],
  88. date:Number(new Date()),
  89. form: {
  90. cartypeId:"",
  91. cartypeName:"",
  92. categorytwoId:"",//id
  93. categorytwoName:"",
  94. type:"",//类型
  95. model:"",//车辆型号
  96. date:"",//时间
  97. distance:"",//距离
  98. price:"",//价格
  99. contacts:"",//联系人
  100. phone:"",//联系人电话
  101. remark:"",//备注
  102. },
  103. rules: {
  104. categorytwoName:[
  105. {
  106. type: 'string',
  107. required: true,
  108. message: '请填写类型',
  109. trigger: ['blur', 'change']
  110. }
  111. ],
  112. model:[
  113. {
  114. type: 'string',
  115. required: true,
  116. message: '请选择车辆型号',
  117. trigger: ['blur', 'change']
  118. }
  119. ],
  120. // date:[
  121. // {
  122. // validator: (rule, value, callback) => {
  123. // console.info(this.form.cartypeName)
  124. // return this.form.cartypeName=='新车' ? false : callback(new Error('请填写时间'))
  125. // },
  126. // message: '请填写时间',
  127. // trigger: ['blur', 'change']
  128. // }
  129. // ],
  130. distance:[
  131. {
  132. type: 'string',
  133. required: true,
  134. message: '请填写公里数',
  135. trigger: ['blur', 'change']
  136. }
  137. ],
  138. price:[
  139. {
  140. type: 'string',
  141. required: true,
  142. message: '请填写价格',
  143. trigger: ['blur', 'change']
  144. }
  145. ],
  146. contacts:[
  147. {
  148. type: 'string',
  149. required: true,
  150. message: '请填写联系人',
  151. trigger: ['blur', 'change']
  152. }
  153. ],
  154. phone:[
  155. {
  156. type: 'string',
  157. required: true,
  158. message: '请填写联系电话',
  159. trigger: ['blur', 'change']
  160. }
  161. ],
  162. }
  163. }
  164. },
  165. onLoad(options) {
  166. // this.onQueryTypeList()
  167. this.onQueryCategoryList()
  168. },
  169. watch: {
  170. },
  171. methods: {
  172. handleCartype(event){
  173. this.form.cartypeId = event.id
  174. this.form.cartypeName = event.name
  175. this.categoryTwoList =event.carrentCategorytwoList
  176. this.form.categorytwoId = ""
  177. this.form.categorytwoName = ""
  178. if(this.form.cartypeName=='新车'){
  179. this.form.date = ""
  180. }
  181. },
  182. onQueryCategoryList(){
  183. let that = this
  184. queryCategoryList({}).then(response=>{
  185. console.info("queryCategoryList",response)
  186. if(response.result.length>0){
  187. that.categoryList = response.result
  188. that.form.cartypeId = response.result[0].id
  189. that.form.cartypeName = response.result[0].name
  190. that.categoryTwoList = response.result[0].carrentCategorytwoList
  191. }
  192. }).catch(error=>{
  193. })
  194. },
  195. onCancel(){
  196. this.form.date = '';
  197. this.showDate = false
  198. },
  199. onConfirm(e){
  200. this.form.date = e.value[0];
  201. this.showDate = false
  202. // console.info('e',e)
  203. // const date = new Date(e.value);
  204. // const year = date.getFullYear();
  205. // const month = String(date.getMonth() + 1).padStart(2, '0');
  206. // const day = String(date.getDate()).padStart(2, '0');
  207. // this.form.date = `${year}-${month}-${day}`;
  208. // this.showDate = false
  209. },
  210. categoryTwoSelect(event){
  211. this.form.categorytwoId = event.id
  212. this.form.categorytwoName = event.name
  213. },
  214. onQueryTypeList(){
  215. queryTypeList({}).then(response=>{
  216. console.info("queryTypeList",response)
  217. this.actions = response.result
  218. }).catch(error=>{
  219. })
  220. },
  221. onSubmit() {
  222. this.$refs.uForm.validate().then(res => {
  223. this.onAddApply()
  224. // uni.$u.toast('校验通过')
  225. }).catch(errors => {
  226. console.info(errors)
  227. // uni.$u.toast('校验失败')
  228. })
  229. },
  230. onAddApply(){
  231. let that = this
  232. if(that.form.cartypeName!='新车' && !that.form.date){
  233. return uni.$u.toast('请选择时间')
  234. }
  235. let params={
  236. categoryoneId:that.form.cartypeId,
  237. categorytwoId:that.form.categorytwoId,
  238. model:that.form.model,
  239. carTime:Number(that.form.date),
  240. mileage:that.form.distance,
  241. name:that.form.contacts,
  242. phone:that.form.phone,
  243. remark:that.form.remark
  244. }
  245. addApply(params).then(response=>{
  246. uni.$u.toast(response.message)
  247. setTimeout(()=>{
  248. uni.navigateBack({
  249. delta:1
  250. })
  251. },1500)
  252. }).catch(error=>{
  253. })
  254. },
  255. },
  256. onReady() {
  257. this.$refs.uForm.setRules(this.rules)
  258. }
  259. }
  260. </script>
  261. <style>
  262. page {
  263. background-color: #f5f5f5 !important;
  264. }
  265. </style>