index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="page-container">
  3. <view class="page-head">
  4. <text>{{titleObj[model.form.scanType]}}</text>
  5. </view>
  6. <view class="page-body">
  7. <u--form label-width="auto" labelAlign="left"
  8. ref="uForm"
  9. :model="model"
  10. :rules="rules"
  11. :labelStyle="{
  12. fontSize: '28rpx',
  13. fontWeight: '500',
  14. }"
  15. >
  16. <u-cell-group :border="false">
  17. <template>
  18. <view class="box" style="margin: 24rpx 24rpx 0rpx 24rpx;">
  19. <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  20. <view slot="value" class="value">
  21. <u-form-item label="" labelPosition="" prop="form.remark" :required="false">
  22. <view slot="label" class="item-label">
  23. <view class="item-label-left">
  24. 驾驶员
  25. </view>
  26. </view>
  27. <view class="item-label-right">{{model.form.driverName}}</view>
  28. </u-form-item>
  29. </view>
  30. </u-cell>
  31. <u-cell title="" :border="false" :isLink="false" :clickable="false" class="hidde-cell-title">
  32. <view slot="value" class="value">
  33. <u-form-item label="" labelPosition="" prop="form.remark" :required="false">
  34. <view slot="label" class="item-label">
  35. <view class="item-label-left">
  36. 车辆
  37. </view>
  38. </view>
  39. <view class="item-label-right">{{model.form.plate}}</view>
  40. </u-form-item>
  41. </view>
  42. </u-cell>
  43. </view>
  44. </template>
  45. </u-cell-group>
  46. </u--form>
  47. </view>
  48. <view class="page-footer">
  49. <u-row style="">
  50. <u-col :span="12">
  51. <u-button type="primary" shape="" :hairline="false" :custom-style="{
  52. width: '100%',
  53. borderRadius: '0',
  54. height: '100rpx',
  55. fontSize: '32rpx',
  56. fontWeight: '500',
  57. background:'linear-gradient(to right, #41B5FF, #4573FC)'
  58. }" @click="handleSubmit">确认
  59. </u-button>
  60. </u-col>
  61. </u-row>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {userProfile} from '@/api/common/user.js'
  67. import {checkHasOutRec,scanVehCode} from '@/api/vehDispatch/taskQrCode.js'
  68. import {clearProps,copyProps} from '@/utils/gdtq.js'
  69. import {isEmpty} from 'lodash'
  70. export default {
  71. components: {
  72. },
  73. data() {
  74. return {
  75. titleObj: {
  76. 1: '是否确认出车?',
  77. 2: '是否确认还车?',
  78. },
  79. model: {
  80. form: {
  81. recId: "", //出车记录ID (还车时,传该参数)
  82. scanType: "", //扫码类型 1出车 2还车
  83. vehicleId: "", //车辆ID (出车时,传该参数)
  84. driverName: '',
  85. plate: '',
  86. }
  87. },
  88. rules: {
  89. 'form.outflowType': [
  90. {
  91. type: 'string',
  92. required: true,
  93. message: '请选择',
  94. trigger: ['blur', 'change']
  95. },
  96. ],
  97. 'form.backDate': {
  98. type: 'string',
  99. required: true,
  100. message: '请选择',
  101. trigger: ['blur', 'change']
  102. },
  103. 'form.outList': {
  104. type: 'array',
  105. required: true,
  106. message: '请选择',
  107. trigger: ['blur', 'change']
  108. },
  109. },
  110. userInfo: null,
  111. params: null,
  112. copyItem: null,
  113. }
  114. },
  115. onLoad(params) {
  116. // console.log(id,'id')
  117. this.params = params
  118. setTimeout(() => {
  119. this.initData()
  120. },500)
  121. },
  122. async created() {
  123. // this.getUserInfo()
  124. },
  125. onShow() {
  126. },
  127. onHide() {
  128. },
  129. onReady() {
  130. // this.resetRules()
  131. },
  132. methods: {
  133. async initData() {
  134. let {vehicleId} = this.params
  135. let {code,data} = await checkHasOutRec({vehicleId})
  136. if(code == 0) {
  137. this.copyItem = data
  138. if(data.hasRec) {
  139. this.model.form.scanType = 2
  140. } else {
  141. this.model.form.scanType = 1
  142. }
  143. this.model.form.driverName = data.driverName
  144. this.model.form.vehicleId = data.vehicleId
  145. this.model.form.plate = data.plate
  146. this.model.form.recId = data.id
  147. }
  148. },
  149. resetRules() {
  150. this.$refs.uForm.setRules(this.rules)
  151. },
  152. async getInfo(id) {
  153. let {code,data} = await queryOneById({id})
  154. if(code == 0) {
  155. copyProps(this.model.form,data)
  156. }
  157. },
  158. getUserInfo() {
  159. userProfile().then((res) => {
  160. this.userInfo = res.data
  161. this.model.form.outflowUserId = res.data.userId
  162. this.model.form.outflowUser = res.data.nickName
  163. this.model.form.deptId = res.data.deptId
  164. this.model.form.deptName = res.data.deptName
  165. })
  166. },
  167. // 提交
  168. async handleSubmit() {
  169. let titleObj = {
  170. 1: '已出车',
  171. 2: '已还车',
  172. }
  173. this.$refs.uForm.validate().then(async res => {
  174. let ajaxData = {
  175. ...this.model.form,
  176. }
  177. let { data, code,msg } = await scanVehCode(ajaxData)
  178. if (code == 0) {
  179. uni.showModal({
  180. title: '提示',
  181. content: `${titleObj[ajaxData.scanType]}`,
  182. showCancel:false,
  183. confirmText: '好的',
  184. success: function(res) {
  185. if (res.confirm) {
  186. uni.switchTab({url: '/pages/index/index'})
  187. }
  188. }
  189. })
  190. }
  191. }).catch(errors => {
  192. console.log('校验失败',errors)
  193. })
  194. },
  195. handleClear() {
  196. clearProps(this.model.form,[])
  197. },
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. .disflex-center {
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. }
  207. .disflex-right {
  208. display: flex;
  209. justify-content: right;
  210. align-items: center;
  211. }
  212. .page-container {
  213. font-size: 28rpx;
  214. min-height: 100%;
  215. position: relative;
  216. background: #fff;
  217. // padding-bottom: 60rpx;
  218. .page-head {
  219. text-align: center;
  220. font-size: 40rpx;
  221. font-weight: 700;
  222. padding: 40rpx 0;
  223. }
  224. .page-body {
  225. padding-bottom: 120rpx;
  226. .box {
  227. margin: 24rpx 24rpx 0;
  228. padding: 20rpx;
  229. border-radius: 20rpx;
  230. background: #fff;
  231. border: 1rpx solid #EBEDF0;
  232. .item-label {
  233. display: flex;
  234. justify-content: space-between;
  235. align-items: center;
  236. &-left {
  237. font-family: PingFangSC, PingFang SC;
  238. font-weight: 400;
  239. font-size: 32rpx;
  240. color: #999999;
  241. position: relative;
  242. text {
  243. color: #f56c6c;
  244. font-size: 40rpx;
  245. position: absolute;
  246. left: -18rpx;
  247. }
  248. }
  249. &-right {
  250. font-family: PingFangSC, PingFang SC;
  251. font-weight: 400;
  252. font-size: 32rpx;
  253. color: #333333;
  254. text-align: right;
  255. width: 100%;
  256. }
  257. }
  258. }
  259. }
  260. .page-footer {
  261. padding: 0rpx 0;
  262. position: fixed;
  263. width: 100%;
  264. left: 0;
  265. bottom: 0;
  266. }
  267. }
  268. ::v-deep {
  269. .u-form-item__body {
  270. padding: 0;
  271. }
  272. .hidde-cell-title {
  273. .u-cell__body__content {
  274. width: auto;
  275. flex: none;
  276. }
  277. .u-cell__body {
  278. .value {
  279. flex: 1;
  280. }
  281. }
  282. }
  283. }
  284. </style>