contract_detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class="container">
  3. <view class="information">
  4. <view class="c-row">
  5. <view class="title1">发车信息</view>
  6. </view>
  7. <u-form :model="goods" ref="uForm" class="uForm">
  8. <u-form-item label="派车编号" prop="tranCarNo" label-width="160" required>
  9. <u-input v-model="goods.tranCarNo" input-align="right" placeholder="请输入派车编号" />
  10. </u-form-item>
  11. <u-form-item label="车牌号" prop="carNo" label-width="160" required>
  12. <u-input v-model="goods.carNo" input-align="right" placeholder="请输入车牌号" />
  13. </u-form-item>
  14. <u-form-item label="司机手机号" prop="driverPhone" label-width="160" required>
  15. <u-input v-model="goods.driverPhone" input-align="right" placeholder="请输入司机手机号" />
  16. </u-form-item>
  17. <u-form-item label="毛重(吨)" prop="grossWeight" label-width="160" required>
  18. <u-input v-model="goods.grossWeight" input-align="right" placeholder="请输入毛重"
  19. @input="grossWeightchange" />
  20. </u-form-item>
  21. <u-form-item label="皮重(吨)" prop="tare" label-width="160" required>
  22. <u-input v-model="goods.tare" input-align="right" placeholder="请输入皮重" @input="tarechange" />
  23. </u-form-item>
  24. <u-form-item label="净重(吨)" prop="reciveNetWeight" label-width="160" required>
  25. <u-input v-model="goods.reciveNetWeight" input-align="right" disabled="" placeholder="自动计算" />
  26. </u-form-item>
  27. <u-form-item label="发货日期" label-width="160" required>
  28. <view @click="show = true" class="time-style">
  29. {{goods.dispatchingDate!=''?goods.dispatchingDate:time}}
  30. </view>
  31. <u-picker :params='params' :default-time='time' @confirm="DateChange" v-model="show" mode="time">
  32. </u-picker>
  33. </u-form-item>
  34. </u-form>
  35. </view>
  36. <view class="information">
  37. <view class="c-row">
  38. <view class="action">
  39. 上传磅单照片
  40. </view>
  41. </view>
  42. <view class="c-row">
  43. <view class="grid col-4 grid-square flex-sub">
  44. <view class="bg-img" v-if="goods.collectionScreenshot != ''" @tap="ViewImage"
  45. :data-url="goods.collectionScreenshot">
  46. <image :src="goods.collectionScreenshot" mode="aspectFit"></image>
  47. <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="0">
  48. <text class='cuIcon-close'></text>
  49. </view>
  50. </view>
  51. <view class="solids" @tap="ChooseImagePerson" v-if="goods.collectionScreenshot == ''">
  52. <text class='cuIcon-cameraadd'></text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <button class="btn btns" @click="getList">提交</button>
  58. <!-- </block> -->
  59. </view>
  60. </template>
  61. <script>
  62. import uploadImage from '@/components/ossutil/uploadFile.js';
  63. import {
  64. mapState
  65. } from 'vuex';
  66. export default {
  67. name: "trust",
  68. data() {
  69. return {
  70. show: false,
  71. goods: {
  72. tranCarNo: '',
  73. carNo: '',
  74. driverPhone: '',
  75. grossWeight: '',
  76. tare: '',
  77. reciveNetWeight: '',
  78. collectionScreenshot: '',
  79. dispatchingDate: '',
  80. // compId: '2710b21efc1e4393930c5dc800010dc4',
  81. batch: ""
  82. },
  83. rules: {
  84. tranCarNo: [{
  85. validator: (rule, value, callback) => {
  86. return !this.$u.test.isEmpty(value)
  87. },
  88. message: '派车编号不能为空',
  89. trigger: ['change', 'blur']
  90. }],
  91. carNo: [{
  92. validator: (rule, value, callback) => {
  93. return this.$u.test.carNo(value)
  94. },
  95. message: '车牌号格式不正确',
  96. trigger: ['change', 'blur']
  97. }],
  98. driverPhone: [{
  99. validator: (rule, value, callback) => {
  100. return this.$u.test.mobile(value);
  101. },
  102. message: '手机号格式不正确',
  103. trigger: ['change', 'blur']
  104. }],
  105. grossWeight: [{
  106. validator: (rule, value, callback) => {
  107. return !this.$u.test.isEmpty(value)
  108. },
  109. message: '毛重不能为空',
  110. trigger: ['change', 'blur']
  111. },
  112. {
  113. validator: (rule, value, callback) => {
  114. return this.$u.test.amount(value)
  115. },
  116. message: '数值类型,最多保留两位小数',
  117. trigger: ['change', 'blur'],
  118. },
  119. {
  120. validator: (rule, value, callback) => {
  121. return this.$u.test.range(value, [1, 100])
  122. },
  123. message: '数值类型,1-100之间',
  124. trigger: ['change', 'blur'],
  125. },
  126. ],
  127. tare: [{
  128. validator: (rule, value, callback) => {
  129. return !this.$u.test.isEmpty(value)
  130. },
  131. message: '皮重不能为空',
  132. trigger: ['change', 'blur']
  133. },
  134. {
  135. validator: (rule, value, callback) => {
  136. return this.$u.test.amount(value)
  137. },
  138. message: '数值类型,最多保留两位小数',
  139. trigger: ['change', 'blur'],
  140. },
  141. {
  142. validator: (rule, value, callback) => {
  143. return this.$u.test.range(value, [1, 50])
  144. },
  145. message: '数值类型,1-50之间',
  146. trigger: ['change', 'blur'],
  147. },
  148. ],
  149. },
  150. params: {
  151. year: true,
  152. month: true,
  153. day: true,
  154. }
  155. };
  156. },
  157. computed: {
  158. ...mapState(['hasLogin', 'userInfo']),
  159. time() {
  160. var date = new Date()
  161. var year = date.getFullYear()
  162. var month = date.getMonth()
  163. var date1 = date.getDate()
  164. if (month + 1 < 10) {
  165. month = "0" + (month + 1)
  166. }
  167. if (date1 + 1 < 10) {
  168. date1 = "0" + date1
  169. }
  170. return year + '-' + month + "-" + date1
  171. },
  172. startDate() {
  173. //限制开始时间;
  174. //也可以直接限定为当天日期 var date= new Date(); return date
  175. return new Date(new Date(new Date().toLocaleDateString()).getTime() - (1 * 60 * 60 * 1000))
  176. },
  177. endDate() {
  178. return new Date()
  179. }
  180. },
  181. onShow() {},
  182. onReady() {
  183. this.$refs.uForm.setRules(this.rules);
  184. },
  185. onLoad(option) {
  186. this.goods.dispatchingDate = this.time;
  187. this.goods.batch = option.id;
  188. },
  189. methods: {
  190. DateChange(e) {
  191. this.goods.sendDateStart = e.year + '-' + e.month + '-' + e.day
  192. },
  193. commit1(item) {
  194. uni.navigateTo({
  195. url: `/pageB/contract/look?id=${item.id}&netWeight=${item.netWeight}&carNo=${item.carNo}&sendDateStart=${item.sendDateStart}`
  196. })
  197. },
  198. grossWeightchange(e) {
  199. if (this.goods.grossWeight && this.goods.tare) {
  200. this.goods.reciveNetWeight = Number(
  201. this.goods.grossWeight - this.goods.tare
  202. )
  203. }
  204. },
  205. tarechange(e) {
  206. if (this.goods.grossWeight && this.goods.tare) {
  207. this.goods.reciveNetWeight = Number(
  208. this.goods.grossWeight - this.goods.tare
  209. )
  210. }
  211. },
  212. getList() {
  213. this.grossWeight = parseInt(this.grossWeight)
  214. var that = this
  215. uni.showModal({
  216. content: '确定提交发车信息?',
  217. success: function(res) {
  218. if (res.confirm) {
  219. that.$refs.uForm.validate(valid => {
  220. if (valid) {
  221. console.log('验证通过');
  222. that.$api.doRequest('post',
  223. '/freightReceivingDispatching/api/insertFreightReceivingDispatchingCar',
  224. that.goods).then(res => {
  225. if (res.data.code == 200) {
  226. console.log(that.goods)
  227. uni.showModal({
  228. content: '提交成功!',
  229. cancelText: "返回",
  230. confirmText: "继续添加",
  231. success: function(res) {
  232. if (res.confirm) {
  233. that.goods = {
  234. carNo: '',
  235. collectionScreenshot: '',
  236. dispatchingDate: '',
  237. loadNetWeight: '',
  238. driverPhone: '',
  239. reciveNetWeight: '',
  240. tare: '',
  241. tranCarNo: ''
  242. }
  243. } else if (res.cancel) {
  244. // uni.navigateBack({
  245. // delta: 1,
  246. // success: function() {
  247. // beforePage.$vm.init();
  248. // }
  249. // });
  250. }
  251. }
  252. });
  253. } else if (res.data.code == 11015) {
  254. uni.showToast({
  255. title: '该司机未认证身份,请司机认证后再操作',
  256. icon: 'none',
  257. duration: 2000
  258. })
  259. }
  260. })
  261. .catch(res => {
  262. if(res.errmsg){
  263. uni.showToast({
  264. title: res.errmsg,
  265. icon: 'none',
  266. duration: 2000
  267. })
  268. }
  269. else{
  270. uni.showToast({
  271. title: "系统异常,请联系管理员",
  272. icon: 'none',
  273. duration: 2000
  274. })
  275. }
  276. });
  277. } else {
  278. console.log('验证失败');
  279. }
  280. });
  281. } else if (res.cancel) {
  282. }
  283. }
  284. });
  285. },
  286. ChooseImagePerson() {
  287. uni.chooseImage({
  288. count: 1, //默认9
  289. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  290. sourceType: ['album', 'camera'], //从相册选择
  291. success: (res) => {
  292. //上传图片
  293. //图片路径可自行修改
  294. uploadImage(res.tempFilePaths[0], 'collectionScreenshot/',
  295. result => {
  296. this.goods.collectionScreenshot = result
  297. uni.hideLoading();
  298. }
  299. )
  300. }
  301. });
  302. },
  303. ChooseImageDriver() {
  304. uni.chooseImage({
  305. count: 1, //默认9
  306. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  307. sourceType: ['album', 'camera'], //从相册选择
  308. success: (res) => {
  309. //上传图片
  310. //图片路径可自行修改
  311. uploadImage(res.tempFilePaths[0], 'driverNoImg/',
  312. result => {
  313. if (this.driverNoImg.length != 0) {
  314. this.driverNoImg1 = result
  315. } else {
  316. this.driverNoImg = result
  317. }
  318. uni.hideLoading();
  319. }
  320. )
  321. }
  322. });
  323. },
  324. ChooseImageCar() {
  325. uni.chooseImage({
  326. count: 1, //默认9
  327. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  328. sourceType: ['album', 'camera'], //从相册选择
  329. success: (res) => {
  330. //上传图片
  331. //图片路径可自行修改
  332. uploadImage(res.tempFilePaths[0], 'carNoImg/',
  333. result => {
  334. if (this.carNoImg.length != 0) {
  335. this.carNoImg1 = result
  336. } else {
  337. this.carNoImg = result
  338. }
  339. uni.hideLoading();
  340. }
  341. )
  342. }
  343. });
  344. },
  345. ViewImage(e) {
  346. var img = [];
  347. img = e.currentTarget.dataset.url.split(' ')
  348. uni.previewImage({
  349. current: 0,
  350. urls: img
  351. });
  352. },
  353. DelImg(e) {
  354. uni.showModal({
  355. title: '提示',
  356. content: '确定要删除该照片吗?',
  357. cancelText: '取消',
  358. confirmText: '确定',
  359. success: res => {
  360. if (res.confirm) {
  361. this.goods.collectionScreenshot = ""
  362. }
  363. }
  364. })
  365. },
  366. },
  367. }
  368. </script>
  369. <style scoped>
  370. .container {
  371. padding: 10px 10px;
  372. background-color: #F5F6FA;
  373. }
  374. .title1 {
  375. font-size: 18px;
  376. font-weight: 600;
  377. }
  378. .cu-form-group input {
  379. text-align: right;
  380. }
  381. .text-white text {
  382. background: linear-gradient(45deg, #3DC146, #B2D612);
  383. padding: 5px 10px;
  384. border-radius: 38rpx;
  385. }
  386. .cu-form-group textarea {
  387. text-align: right;
  388. }
  389. .commit {
  390. background: linear-gradient(45deg, #DF331C, #DA611A);
  391. color: #fff;
  392. }
  393. .c-row {
  394. display: -webkit-box;
  395. display: -webkit-flex;
  396. display: flex;
  397. -webkit-box-align: center;
  398. -webkit-align-items: center;
  399. align-items: center;
  400. padding: 20rpx 30rpx;
  401. position: relative;
  402. }
  403. .con-list {
  404. -webkit-box-flex: 1;
  405. -webkit-flex: 1;
  406. flex: 1;
  407. display: -webkit-box;
  408. display: -webkit-flex;
  409. display: flex;
  410. -webkit-box-orient: vertical;
  411. -webkit-box-direction: normal;
  412. -webkit-flex-direction: column;
  413. flex-direction: column;
  414. color: #303133;
  415. line-height: 40rpx;
  416. text-align: right;
  417. padding-right: 20rpx;
  418. font-size: 14px;
  419. }
  420. .information {
  421. background-color: #FFFFFF;
  422. border-radius: 20px;
  423. margin-top: 10px;
  424. }
  425. .btn {
  426. margin-top: 10px;
  427. border-radius: 25px;
  428. background-color: #22C572;
  429. border: none;
  430. color: #FFFFFF;
  431. }
  432. .uForm {
  433. padding: 0 40rpx;
  434. }
  435. .time-style {
  436. position: absolute;
  437. right: 0;
  438. }
  439. </style>