contract_detail.vue 13 KB

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