submit.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="checkSubmit">
  3. <view class="commons-title">
  4. 面料信息
  5. </view>
  6. <view class="submit-warp">
  7. <view class="form-text">
  8. 面料
  9. </view>
  10. <view class="form-box">
  11. <view>
  12. <view class="" style="text-align: left;display: flex;justify-content: space-between;">
  13. <view class="" style="color:#999;width:90%" @click="openSelectQd('mianliao')">
  14. {{formData.materialName || '请选择面料 '}}
  15. </view>
  16. <uni-icons @click="openSelectQd(index)" type="forward" size="20"></uni-icons>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="submit-warp" style="margin-top:40rpx">
  22. <view class="form-text">
  23. 供应商
  24. </view>
  25. <view class="form-box">
  26. <view>
  27. <view class="" style="text-align: left;display: flex;justify-content: space-between;">
  28. <view class="" style="color:#999;width:90%" @click="openSelectQd('gongyingshang')">
  29. {{formData.supplierName || '请选择供应商 '}}
  30. </view>
  31. <uni-icons @click="openSelectQd(index)" type="forward" size="20"></uni-icons>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="commons-title">
  37. 拍照上传
  38. </view>
  39. <view class="form-box" style="margin:0 30rpx">
  40. <view class="imglist">
  41. <view class="item" v-for="(item,index) in imgs" :key="item" v-if="!item.loadingType">
  42. <image :src="item" alt=""></image>
  43. <view class='delete' bindtap='deleteImg' @click="imgDelete(index)">
  44. x
  45. </view>
  46. </view>
  47. <view class="item" v-else>
  48. <image src="../../static/loding.gif"></image>
  49. </view>
  50. <view class="last-item" @click="bindUpload">
  51. <text class="sign">+</text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="commons-title">
  56. 问题选择
  57. </view>
  58. <view class="wenti-list">
  59. <view class="list-box" :class="i.active ? 'active' : ''" v-for="(i,index) in wentiList" :key="i.type" @click="wentiSelect(i,index)">
  60. {{i.name}}
  61. </view>
  62. </view>
  63. <view class="" style="margin: 0 20rpx 20rpx;border:1px solid #dcdcdc;">
  64. <textarea style="width:100%;padding:20rpx" v-model="formData.remark" placeholder="备注信息"/>
  65. </view>
  66. <view class="submit-btn-warp">
  67. <button @click="checkSubmit(2)" style="background:#EF0000;color:#fff;margin-bottom: 30rpx;">取消</button>
  68. <button @click="checkSubmit(1)" style="background:#1A3AF0; color:#fff;margin-bottom: 30rpx;">提交</button>
  69. </view>
  70. <uni-popup ref="popup2" type="top">
  71. <view class="search-box">
  72. <uni-search-bar @confirm="selectList" v-model="req.search" @cancel="reload">
  73. </uni-search-bar>
  74. <ul>
  75. <li @click="selectMaterialList(i)" v-for="i in range2" :key="i.id">
  76. {{i.name}}
  77. </li>
  78. </ul>
  79. </view>
  80. </uni-popup>
  81. <uni-popup ref="popup" type="top">
  82. <view class="search-box">
  83. <uni-search-bar @confirm="selectList" v-model="req.search" @cancel="reload">
  84. </uni-search-bar>
  85. <ul>
  86. <li @click="selectMaterialList(i)" v-for="i in range" :key="i.id">
  87. {{i.name}}
  88. </li>
  89. </ul>
  90. </view>
  91. </uni-popup>
  92. </view>
  93. </template>
  94. <script>
  95. import {
  96. getInfo
  97. } from "@/util/api.js";
  98. import Vue from 'vue'
  99. // import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
  100. import {
  101. dateFormat,
  102. getTime
  103. } from '../../util/uitl.js'
  104. export default {
  105. components: {
  106. // htzImageUpload,
  107. },
  108. data() {
  109. return {
  110. wentiList:[
  111. {type:1,name:"短少",active:false},
  112. {type:2,name:"抽纱",active:false},
  113. {type:3,name:"褶皱",active:false},
  114. {type:4,name:"脏污",active:false},
  115. {type:5,name:"破洞",active:false},
  116. {type:6,name:"缩水",active:false}
  117. ],
  118. value: 0,
  119. range: [],
  120. range2:[],
  121. formData: {
  122. supplierId:null,
  123. materialId:null,
  124. problemType:'',
  125. remark:null,
  126. attr:[],
  127. supplierName:null,
  128. },
  129. imgs: [],
  130. option: null,
  131. imgUrl: null,
  132. checkListData: [],
  133. optionCopy: null,
  134. materialIndex:null,
  135. req:{
  136. pageNum:1,
  137. pageSize:10,
  138. search:null,
  139. materialCode:null,
  140. },
  141. selectModalType:'gongyingshang',
  142. }
  143. },
  144. onLoad(option) {
  145. const v = this
  146. v.selectList()
  147. },
  148. methods: {
  149. selectMaterialList(i){
  150. const v = this
  151. if(v.selectModalType == 'gongyingshang'){
  152. v.formData.supplierId = i.id
  153. v.formData.supplierName = i.name
  154. }else{
  155. v.formData.materialId = i.id
  156. v.formData.materialName = i.name
  157. v.req.materialCode = i.id
  158. }
  159. console.log(i)
  160. this.$refs.popup2.close()
  161. this.$refs.popup.close()
  162. },
  163. openSelectQd(modalType){
  164. const v = this
  165. if(modalType == 'gongyingshang' && v.formData.materialId == null){
  166. wx.showToast({
  167. title: "请先选择面料!",
  168. icon: "none",
  169. duration: 2000
  170. })
  171. return
  172. }
  173. v.selectModalType = modalType
  174. v.req.search = null
  175. v.selectList()
  176. if(modalType == 'gongyingshang'){
  177. this.$refs.popup2.open('top')
  178. }else{
  179. this.$refs.popup.open('top')
  180. }
  181. },
  182. bindPickerChange(e){
  183. console.log(e)
  184. const v = this
  185. v.formData.supplierName = v.range[e.detail.value].bankAccoutName
  186. v.formData.supplierId = v.range[e.detail.value].id
  187. },
  188. selectList(){
  189. const v = this
  190. if(v.selectModalType == 'gongyingshang'){
  191. v.$post('/supplier/selectList',v.req).then(res=>{
  192. console.log(res)
  193. this.range2 = res.data
  194. })
  195. }else{
  196. v.$post('/material/selectList',v.req).then(res=>{
  197. console.log(res)
  198. this.range = res.data
  199. })
  200. }
  201. },
  202. wentiSelect(item,index){
  203. this.wentiList[index].active = !this.wentiList[index].active
  204. },
  205. imgDelete(_index) {
  206. const v = this
  207. v.imgs.splice(_index, 1)
  208. },
  209. bindUpload() {
  210. const v = this
  211. wx.chooseImage({
  212. count: 1,
  213. sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图,默认二者都有
  214. sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有
  215. success: function(res) {
  216. // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
  217. var tempFilePaths = res.tempFilePaths
  218. for (var i = 0; i < tempFilePaths.length; i++) {
  219. v.imgs.push({
  220. loadingType: true
  221. })
  222. wx.uploadFile({
  223. url: 'https://cfm.bytesail.cn/api/storage/cloudApi/applet/uploadFile',
  224. filePath: tempFilePaths[i],
  225. name: "file",
  226. header: {
  227. 'Blade-Auth': 'bearer ' + Vue.prototype.$token.access_token,
  228. 'Authorization':'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
  229. 'Content-Type':'application/json;charset=UTF-8',
  230. },
  231. success: function(res) {
  232. console.log(res.data)
  233. res.data = JSON.parse(res.data)
  234. if (res.data.code == 200) {
  235. wx.showToast({
  236. title: "上传成功",
  237. icon: "none",
  238. duration: 1500
  239. })
  240. v.imgs.splice(-1)
  241. v.imgs.push(res.data.msg)
  242. console.log(v.imgs)
  243. }
  244. },
  245. fail: function(err) {
  246. wx.showToast({
  247. title: "上传失败",
  248. icon: "none",
  249. duration: 2000
  250. })
  251. },
  252. complete: function(result) {
  253. console.log(result.errMsg)
  254. }
  255. })
  256. }
  257. }
  258. })
  259. },
  260. zidingyiSuccess() {
  261. },
  262. checkSubmit(_type) {
  263. const v = this
  264. if(_type == 2){
  265. wx.reLaunch({
  266. url: '/pages/home'
  267. })
  268. }
  269. v.formData.problemType = ''
  270. v.formData.attr = []
  271. for (var i = 0; i < v.imgs.length; i++) {
  272. v.formData.attr.push({
  273. realName:"xxx",
  274. path:v.imgs[i]
  275. })
  276. }
  277. for (var i = 0; i < v.wentiList.length; i++) {
  278. if(v.wentiList[i].active){
  279. v.formData.problemType = v.formData.problemType + v.wentiList[i].type + ','
  280. }
  281. }
  282. if(v.formData.problemType == ''){
  283. uni.showToast({
  284. title: '请选择问题类型!'
  285. })
  286. return
  287. }
  288. v.formData.problemType = v.formData.problemType.slice(0,v.formData.problemType.length - 1)
  289. uni.showLoading({title: '加载中',mask:true});
  290. v.$post('/supplierProblem/add', v.formData).then(res => {
  291. if (res.code == 200) {
  292. uni.hideLoading()
  293. uni.showToast({
  294. title: '提交成功,跳转中!'
  295. })
  296. setTimeout(() => {
  297. wx.reLaunch({
  298. url: '/pages/home'
  299. })
  300. }, 2000)
  301. }
  302. })
  303. },
  304. select(e) {
  305. console.log(e)
  306. const v = this
  307. v.$post('/wx/common/uploadFile', {
  308. file: e.tempFilePaths[0]
  309. }).then(res => {
  310. })
  311. },
  312. },
  313. }
  314. </script>
  315. <style lang="less" scoped>
  316. .search-box{
  317. background-color: #fff;
  318. ul{
  319. li{
  320. padding: 25rpx 30rpx;
  321. border-bottom: 1rpx solid #dcdcdc;
  322. }
  323. }
  324. }
  325. .submit-btn-warp{
  326. display: flex;
  327. justify-content: space-between;
  328. button{
  329. width: 47%;
  330. }
  331. }
  332. .wenti-list{
  333. overflow: hidden;
  334. .list-box{
  335. width: 28%;
  336. margin: 0 2% 20rpx;
  337. float: left;
  338. height: 60rpx;
  339. line-height: 60rpx;
  340. text-align: center;
  341. border:1px solid #DDDCDC;
  342. border-radius: 10rpx;
  343. }
  344. .list-box.active{
  345. border:1px solid #1A3AF0;
  346. background-color: #1A3AF0;
  347. color: #fff;
  348. }
  349. }
  350. .submit-warp{
  351. display: flex;
  352. .form-text{
  353. width: 20%;
  354. text-align: center;
  355. }
  356. .form-box{
  357. width: 80%;
  358. padding: 0 20rpx;
  359. }
  360. }
  361. .imglist {
  362. display: flex;
  363. flex-wrap: wrap;
  364. }
  365. .imglist .item {
  366. width: 150rpx;
  367. height: 150rpx;
  368. margin-right: 22rpx;
  369. margin-bottom: 10rpx;
  370. position: relative;
  371. }
  372. .imglist .last-item {
  373. width: 150rpx;
  374. height: 150rpx;
  375. text-align: center;
  376. line-height: 146rpx;
  377. border: 2rpx dashed #8B97A9;
  378. box-sizing: border-box;
  379. }
  380. .imglist .item image {
  381. width: 100%;
  382. height: 100%;
  383. }
  384. .imglist .item .delete {
  385. width: 30rpx;
  386. height: 30rpx;
  387. position: absolute;
  388. top: -25rpx;
  389. right: -12rpx;
  390. font-size: 40rpx;
  391. font-weight: bold;
  392. }
  393. </style>