submit.vue 9.0 KB

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