环卫车小程序前端代码
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.

217 lines
5.2 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months 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 label="类型" prop="type" @click="showType=true">
  5. <u--input border="bottom" v-model="form.type" disabled placeholder="请填写类型"></u--input>
  6. <u-icon slot="right" name="arrow-right"></u-icon>
  7. </u-form-item>
  8. <u-form-item label="车辆型号" prop="model">
  9. <u--input v-model="form.model" placeholder="请填写车辆型号"></u--input>
  10. </u-form-item>
  11. <u-form-item label="年限" prop="date" @click="showDate=true">
  12. <u--input border="bottom" v-model="form.date" disabled placeholder="请填写年限"></u--input>
  13. <u-icon slot="right" name="arrow-right"></u-icon>
  14. </u-form-item>
  15. <u-form-item label="公里数" prop="distance">
  16. <u--input v-model="form.distance" placeholder="请填写公里数"></u--input>
  17. </u-form-item>
  18. <u-form-item label="联系人" prop="contacts">
  19. <u--input v-model="form.contacts" placeholder="请填写联系人"></u--input>
  20. </u-form-item>
  21. <u-form-item label="联系电话" prop="phone">
  22. <u--input v-model="form.phone" placeholder="请填写联系电话"></u--input>
  23. </u-form-item>
  24. <u-form-item label="备注" labelPosition="top" prop="remark">
  25. <u--textarea class="se-mt-20" v-model="form.remark" count
  26. placeholder="请填写备注"></u--textarea>
  27. </u-form-item>
  28. <u-form-item>
  29. <view class="se-px-20 se-pt-20">
  30. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  31. <view @click="onSubmit"
  32. 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">
  33. <text>确认申请</text>
  34. </view>
  35. </view>
  36. </view>
  37. </u-form-item>
  38. </u--form>
  39. <u-action-sheet
  40. :show="showType"
  41. :actions="actions"
  42. title="请选择类型"
  43. @close="showType = false"
  44. @select="typeSelect"
  45. >
  46. </u-action-sheet>
  47. <u-datetime-picker
  48. :show="showDate"
  49. v-model="date"
  50. mode="date"
  51. @confirm="onConfirm"
  52. @cancel="onCancel"
  53. ></u-datetime-picker>
  54. </view>
  55. </template>
  56. <script>
  57. import { queryTypeList,addApply } from "@/common/api.js"
  58. export default {
  59. components:{
  60. },
  61. data() {
  62. return {
  63. showDate:false,
  64. showType:false,
  65. actions: [],
  66. date:Number(new Date()),
  67. form: {
  68. categorytwoId:"",//id
  69. type:"",//类型
  70. model:"",//车辆型号
  71. date:"",//时间
  72. distance:"",//距离
  73. price:"",//价格
  74. contacts:"",//联系人
  75. phone:"",//联系人电话
  76. remark:"",//备注
  77. },
  78. rules: {
  79. type:[
  80. {
  81. type: 'string',
  82. required: true,
  83. message: '请填写类型',
  84. trigger: ['blur', 'change']
  85. }
  86. ],
  87. model:[
  88. {
  89. type: 'string',
  90. required: true,
  91. message: '请选择车辆型号',
  92. trigger: ['blur', 'change']
  93. }
  94. ],
  95. date:[
  96. {
  97. type: 'string',
  98. required: true,
  99. message: '请填写时间',
  100. trigger: ['blur', 'change']
  101. }
  102. ],
  103. distance:[
  104. {
  105. type: 'string',
  106. required: true,
  107. message: '请填写公里数',
  108. trigger: ['blur', 'change']
  109. }
  110. ],
  111. price:[
  112. {
  113. type: 'string',
  114. required: true,
  115. message: '请填写价格',
  116. trigger: ['blur', 'change']
  117. }
  118. ],
  119. contacts:[
  120. {
  121. type: 'string',
  122. required: true,
  123. message: '请填写联系人',
  124. trigger: ['blur', 'change']
  125. }
  126. ],
  127. phone:[
  128. {
  129. type: 'string',
  130. required: true,
  131. message: '请填写联系电话',
  132. trigger: ['blur', 'change']
  133. }
  134. ],
  135. }
  136. }
  137. },
  138. onLoad(options) {
  139. this.onQueryTypeList()
  140. },
  141. watch: {
  142. },
  143. methods: {
  144. onCancel(){
  145. this.showDate = false
  146. },
  147. onConfirm(e){
  148. console.info('e',e)
  149. const date = new Date(e.value);
  150. const year = date.getFullYear();
  151. const month = String(date.getMonth() + 1).padStart(2, '0');
  152. const day = String(date.getDate()).padStart(2, '0');
  153. this.form.date = `${year}-${month}-${day}`;
  154. this.showDate = false
  155. },
  156. typeSelect(event) {
  157. console.info(event)
  158. this.form.categorytwoId = event.id
  159. this.form.type = event.name
  160. },
  161. onQueryTypeList(){
  162. queryTypeList({}).then(response=>{
  163. console.info("queryTypeList",response)
  164. this.actions = response.result.records
  165. }).catch(error=>{
  166. })
  167. },
  168. onSubmit() {
  169. this.$refs.uForm.validate().then(res => {
  170. this.onAddApply()
  171. // uni.$u.toast('校验通过')
  172. }).catch(errors => {
  173. // uni.$u.toast('校验失败')
  174. })
  175. },
  176. onAddApply(){
  177. let that = this
  178. let params={
  179. categorytwoId:that.form.categorytwoId,
  180. model:that.form.model,
  181. carTime:that.form.date,
  182. mileage:that.form.distance,
  183. name:that.form.contacts,
  184. phone:that.form.phone,
  185. remark:that.form.remark
  186. }
  187. addApply(params).then(response=>{
  188. uni.$u.toast(response.message)
  189. setTimeout(()=>{
  190. uni.navigateBack({
  191. delta:1
  192. })
  193. },1500)
  194. }).catch(error=>{
  195. })
  196. },
  197. },
  198. onReady() {
  199. this.$refs.uForm.setRules(this.rules)
  200. }
  201. }
  202. </script>
  203. <style>
  204. page {
  205. background-color: #f5f5f5 !important;
  206. }
  207. </style>