add.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="container qualifications" :style="{paddingBottom :isIphoneX ? (218+68)+'rpx' : '218rpx'}">
  3. <view class="qualifications-title">
  4. 若发货商品内存在仪器类商品,建议填写下列商品信息。
  5. </view>
  6. <view class="qualifications-content">
  7. <view class="list" v-for="(item,index) in qualificationsList" :key="index">
  8. <view class="list-view-title">
  9. <view class="title-left">商品{{ index+1 }}</view>
  10. <view class="title-right" v-if="(index+1) > 1" @click="deleteLogistItemFn(item,index)">
  11. 删除商品
  12. </view>
  13. </view>
  14. <view class="list-view">
  15. <view class="list-view-label">商品</view>
  16. <view class="list-view-text">
  17. <picker @change="bindPickerChange(item,$event)" :value="index" :range="productActions" range-key="name">
  18. <input class="input" type="text" v-model="item.productName" placeholder="请选择商品" disabled="true">
  19. <text class="iconfont icon-xiayibu"></text>
  20. </picker>
  21. </view>
  22. </view>
  23. <view class="list-view">
  24. <view class="list-view-label">SN码</view>
  25. <view class="list-view-text">
  26. <input class="input" type="text" v-model="item.sn" placeholder="请输入商品SN码" @blur="hanldSnCodeChecked">
  27. </view>
  28. </view>
  29. <view class="list-view" v-for="(file,fileIndex) in item.fileList" :key="fileIndex">
  30. <view class="list-view-label">资质文件</view>
  31. <view class="list-view-text">
  32. <view class="input">{{ file.fileName }}</view>
  33. <text class="iconfont icon-iconfontguanbi" @click.stop="deleteFileFn(item.fileList,index)"></text>
  34. </view>
  35. </view>
  36. <view class="list-view" >
  37. <view class="list-view-label">资质文件</view>
  38. <view class="list-view-text">
  39. <view class="list-view-file" @click="uploadFile(item.fileList)">上传</view>
  40. </view>
  41. </view>
  42. <view class="list-view-title none">图片<text class="none">(若不方便上传文件,可用图片代替)</text></view>
  43. <view class="list-view-upload clearfix">
  44. <view class="photo-item" v-for="(image, imageIndex) in item.imageList" :key="index">
  45. <image :src="image" mode="aspectFill" @click.stop="previewImg(item.imageList,imageIndex)"></image>
  46. <text class="iconfont icon-iconfontguanbi" @click.stop="deletePhotoFn(item.imageList,imageIndex)"></text>
  47. </view>
  48. <view class="photo-item add" @click.stop="uploadPhotoFn(item.imageList)" v-if="item.imageList.length<10 || item.imageList.length == 0">
  49. <text class="iconfont icon-jiahao"></text>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="list-btn" v-if="qualificationsList.length < productActions.length">
  54. <view class="btn add-btn" @click="addListFn">
  55. <text class="iconfont icon-jiahao"></text>
  56. <text>添加商品</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="qualifications-btn" :style="{paddingBottom :isIphoneX ? '68rpx' : '0'}">
  61. <view class="edit-button-canel" @click="editButtonCanel">暂不填写</view>
  62. <view class="edit-button" @click="editButtonConfim">确定</view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { mapState,mapMutations } from 'vuex'
  68. import authorize from '@/common/config/authorize.js'
  69. import { uploadFileImage , uploadFilePdfDocDocx } from "@/services/public.js"
  70. var isPreviewImg;
  71. export default{
  72. data() {
  73. return{
  74. isIphoneX:this.$store.state.isIphoneX,
  75. shopOrderId:0,
  76. logisticsBatchId:0,
  77. productActions:[],
  78. qualificationsList:[
  79. {
  80. productName:'',
  81. recordId:'',
  82. sn:'',
  83. fileList:[],
  84. imageList:[]
  85. }
  86. ]
  87. }
  88. },
  89. onLoad(option) {
  90. console.log(option)
  91. if(option.type == 'add'){
  92. this.logisticsBatchId = option.logisticsBatchId
  93. this.shopOrderId = option.shopOrderId
  94. this.GetSupplierLogisticsRecord()
  95. }else{
  96. this.logisticsBatchId = option.logisticsBatchId
  97. this.shopOrderId = option.shopOrderId
  98. this.GetSupplierLogisticsRecord()
  99. this.GetSupplierQualificationData()
  100. }
  101. },
  102. methods:{
  103. ...mapMutations(['login']),
  104. GetSupplierQualificationData(){//编辑回显商品资质信息
  105. this.ShopService.GetSupplierQualificationData(
  106. {
  107. logisticsBatchId : this.logisticsBatchId ,
  108. }
  109. )
  110. .then(response =>{
  111. const data = response.data
  112. if(data && data.length > 0){
  113. this.qualificationsList = data
  114. this.isEmpty = false
  115. }else{
  116. this.isEmpty = true
  117. }
  118. })
  119. .catch(error =>{
  120. this.$util.msg(error.msg,2000);
  121. })
  122. },
  123. GetSupplierLogisticsRecord(){//添加商品资质初始化查询商品信息
  124. this.ShopService.GetSupplierLogisticsRecord(
  125. {
  126. logisticsBatchId : this.logisticsBatchId
  127. }
  128. )
  129. .then(response =>{
  130. const data = response.data
  131. data.forEach((el,index) => {
  132. let obj = {
  133. value : el.id,
  134. name : el.productName
  135. }
  136. this.productActions.push(obj)
  137. })
  138. })
  139. .catch(error =>{
  140. this.$util.msg(error.msg,2000);
  141. })
  142. },
  143. editButtonConfim(){//确定
  144. // 校验物流公司不能为空
  145. let isRecordId = false
  146. let isSnCode = false
  147. let isFileList = false
  148. let isImageList = false
  149. let params = [];//参数
  150. this.qualificationsList.forEach((el,index) => {
  151. if(el.recordId == ''){ isRecordId = true }
  152. if(el.sn == ''){ isSnCode = true }
  153. if(el.fileList == ''){ isFileList = true }
  154. if(el.imageList == ''){ isImageList = true }
  155. let paramsObject = {
  156. recordId : el.recordId,
  157. sn : el.sn,
  158. files : el.fileList,
  159. images : el.imageList
  160. }
  161. params.push(paramsObject)
  162. })
  163. if(isRecordId){
  164. this.$util.msg('请选择商品',2000);
  165. return
  166. }
  167. if(isSnCode){
  168. this.$util.msg('请输入商品SN码',2000);
  169. return
  170. }
  171. if(isFileList && isImageList){
  172. this.$util.msg('请上传商品资质文件',2000);
  173. return
  174. }
  175. console.log('params========>',params)
  176. this.ShopService.GetSupplierQualificationUpdata(
  177. {
  178. params:JSON.stringify(params)
  179. }
  180. )
  181. .then(response =>{
  182. this.$util.msg('保存成功',3000,true,'success')
  183. setTimeout(()=>{
  184. this.$api.navigateTo(`/pages/supplier/deliver/deliver-record?shopOrderId=${this.shopOrderId}`)
  185. },2000)
  186. })
  187. .catch(error =>{
  188. this.$util.msg(error.msg,2000);
  189. })
  190. },
  191. bindPickerChange: function(item,e) {//选择筛选条件
  192. item.recordId = this.productActions[e.target.value].value
  193. item.productName = this.productActions[e.target.value].name
  194. },
  195. addListFn(){//添加
  196. let obj ={
  197. productName:'',
  198. recordId:'',
  199. sn:'',
  200. fileList:[],
  201. imageList:[]
  202. };
  203. this.qualificationsList.push(obj)
  204. },
  205. deleteLogistItemFn(item,index){
  206. this.$util.modal('提示','确认删除物流信息吗?','确定','取消',true,() =>{
  207. this.qualificationsList.splice(index, 1);
  208. })
  209. },
  210. uploadFile(array){//上传资质文件
  211. console.log(array)
  212. uploadFilePdfDocDocx().then(res =>{
  213. let data = JSON.parse(res.data).data
  214. let obj = {
  215. fileName:uni.getStorageSync('fileName'),
  216. ossName:data.ossName
  217. }
  218. array.push(obj)
  219. console.log('array',array)
  220. })
  221. },
  222. uploadPhotoFn(array){//添加图片
  223. uploadFileImage().then(res =>{
  224. array.push(JSON.parse(res.data).data)
  225. })
  226. },
  227. deleteFileFn(array,index){//删除文件
  228. this.UploadService.PostFileDelete(
  229. {
  230. ossName:array[index].ossName,
  231. }
  232. )
  233. .then(res=>{
  234. array.splice(index, 1);
  235. })
  236. .catch(error =>{
  237. console.log('删除文件异常提示===>',error.msg)
  238. })
  239. },
  240. deletePhotoFn(array,index){//删除图片
  241. array.splice(index, 1);
  242. },
  243. previewImg (image,index) {//顶部商品图片预览
  244. isPreviewImg = true
  245. let previewUrls = image
  246. uni.previewImage({
  247. current: index, //图片索引
  248. urls: previewUrls, //必须是http图片,本地图片无效
  249. longPressActions:''
  250. })
  251. },
  252. hanldSnCodeChecked(e){
  253. if(!this.$reg.isNoChinese(e.detail.value)){
  254. this.$util.msg('SN码格式错误',2000);
  255. return
  256. }
  257. },
  258. editButtonCanel(){
  259. this.$api.navigateTo(`/pages/supplier/deliver/deliver-record?shopOrderId=${this.shopOrderId}`)
  260. },
  261. },
  262. onShow() {
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. page {
  268. height: auto;
  269. background:#F7F7F7;
  270. }
  271. .qualifications-title{
  272. width: 100%;
  273. height: 72rpx;
  274. line-height: 72rpx;
  275. font-size: $font-size-24;
  276. background-image: linear-gradient(270deg, #ffffff 0%, rgba(225,86,22,0.1) 51%, #ffffff 100%);
  277. color: $color-system;
  278. text-align: center;
  279. }
  280. .qualifications-content{
  281. width: 100%;
  282. height: auto;
  283. .list{
  284. width: 100%;
  285. height: auto;
  286. background-color: #FFFFFF;
  287. box-sizing: border-box;
  288. margin-bottom: 20rpx;
  289. padding: 0 24rpx;
  290. .list-view-title{
  291. width: 100%;
  292. height: 92rpx;
  293. border-bottom: 1px solid #E1E1E1;
  294. line-height: 92rpx;
  295. font-size: $font-size-30;
  296. color: #333333;
  297. text-align: left;
  298. .title-left{
  299. float: left;
  300. }
  301. .title-right{
  302. float: right;
  303. color: $color-system;
  304. font-size: $font-size-24;
  305. }
  306. &.none{
  307. border-bottom: none;
  308. }
  309. .none{
  310. color: #666666;
  311. }
  312. }
  313. .list-view{
  314. width: 100%;
  315. height: 92rpx;
  316. border-bottom: 1px solid #E1E1E1;
  317. line-height: 92rpx;
  318. font-size: $font-size-30;
  319. .list-view-label{
  320. width: 192rpx;
  321. color: #666666;
  322. float: left;
  323. }
  324. .list-view-text{
  325. width: 510rpx;
  326. float: right;
  327. position: relative;
  328. .input{
  329. width: 510rpx;
  330. height: 92rpx;
  331. box-sizing: border-box;
  332. line-height: 92rpx;
  333. color: #333333;
  334. text-overflow: ellipsis;
  335. overflow: hidden;
  336. display: -webkit-box;
  337. -webkit-line-clamp: 1;
  338. line-clamp: 1;
  339. -webkit-box-orient: vertical;
  340. padding-right: 40rpx;
  341. }
  342. .icon-xiayibu{
  343. width: 40rpx;
  344. height: 80rpx;
  345. display: block;
  346. position: absolute;
  347. right: 0;
  348. top: 0;
  349. font-size: $font-size-32;
  350. color: #B2B2B2;
  351. text-align: center;
  352. }
  353. .icon-iconfontguanbi{
  354. width: 40rpx;
  355. height: 40rpx;
  356. border-radius: 50%;
  357. background-color: #f94b4b;
  358. display: block;
  359. position: absolute;
  360. right: 0;
  361. top: 28rpx;
  362. font-size: $font-size-24;
  363. color: #FFFFFF;
  364. line-height: 40rpx;
  365. text-align: center;
  366. }
  367. .list-view-file{
  368. width: 88rpx;
  369. height: 44rpx;
  370. line-height: 44rpx;
  371. font-size: $font-size-20;
  372. text-align: center;
  373. color: #FFFFFF;
  374. background-color: $color-system;
  375. border-radius: 4rpx;
  376. position: absolute;
  377. right: 0;
  378. top: 25rpx;
  379. }
  380. }
  381. }
  382. .list-view-upload{
  383. width: 100%;
  384. height: auto;
  385. padding: 10rpx 0;
  386. .photo-item{
  387. display: inline-block;
  388. width: 112rpx;
  389. height: 112rpx;
  390. margin: 10rpx 0;
  391. margin-right: 25rpx;
  392. border-radius: 10rpx;
  393. border:1px solid #F5F5F5;
  394. position: relative;
  395. float: left;
  396. &.add{
  397. width: 112rpx;
  398. height: 112rpx;
  399. border-color: #b2b2b2;
  400. text-align: center;
  401. line-height: 112rpx;
  402. margin-right: 0rpx;
  403. .icon-jiahao{
  404. font-size: $font-size-44;
  405. color:#b2b2b2 ;
  406. font-weight: bold;
  407. }
  408. }
  409. .icon-iconfontguanbi{
  410. width: 30rpx;
  411. height: 30rpx;
  412. border-radius:50%;
  413. display: block;
  414. position: absolute;
  415. right: -10rpx;
  416. top: -10rpx;
  417. background: #f94b4b;
  418. text-align: center;
  419. line-height: 30rpx;
  420. color: #FFFFFF;
  421. font-size: $font-size-22;
  422. }
  423. image{
  424. width: 112rpx;
  425. height: 112rpx;
  426. border-radius: 10rpx;
  427. }
  428. }
  429. .photo-list{
  430. width: 100%;
  431. height: 116rpx;
  432. overflow: hidden;
  433. white-space: nowrap;
  434. display: flex;
  435. align-items: flex-start;
  436. }
  437. .scoll-wrapper{
  438. display:flex;
  439. align-items: flex-start;
  440. }
  441. }
  442. }
  443. .list-btn{
  444. width: 702rpx;
  445. height: 56rpx;
  446. margin: 0 auto;
  447. .btn{
  448. width: 236rpx;
  449. height: 56rpx;
  450. border-radius: 28rpx;
  451. border: 1px solid $color-system;
  452. line-height: 56rpx;
  453. text-align: center;
  454. color: $color-system;
  455. margin: 0 auto;
  456. }
  457. }
  458. }
  459. .qualifications-btn{
  460. width: 100%;
  461. padding-top: 20rpx;
  462. position: fixed;
  463. bottom: 0;
  464. left: 0;
  465. background-color: #FFFFFF;
  466. .edit-button-canel{
  467. width: 100%;
  468. height: 88rpx;
  469. line-height: 88rpx;
  470. text-align: center;
  471. color: #e15616;
  472. font-size: $font-size-24;
  473. }
  474. .edit-button{
  475. width: 600rpx;
  476. height: 90rpx;
  477. background: $btn-confirm;
  478. line-height: 90rpx;
  479. text-align: center;
  480. color: #FFFFFF;
  481. font-size: $font-size-30;
  482. margin: 0 auto;
  483. border-radius: 45rpx;
  484. }
  485. }
  486. </style>