entryredItem.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="content">
  3. <view style="height: 20rpx;background: #F4F5F7;"></view>
  4. <view class="box">
  5. <view class="boxLine" v-for="(item,index) in categoryList[index1].sectionList[index2].itemList">
  6. <view class="boxLineTop">
  7. <view class="itemName">{{item.itemName}}</view>
  8. <view class="store" v-show="item.keyType==4" @click="pickerClick(item)">
  9. <picker @change="bindPickerChange($event)" :value="item.storeIndex" :item="item" :range="item.array">
  10. <view class="pickerView" v-if="item.itemValue!=null">{{item.itemValue}} 分</view>
  11. <view class="pickerView" v-else>请选择</view>
  12. </picker>
  13. <view>
  14. <image src="../../static/img/jiantou.png" mode="" class="storeJtimg"></image>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="boxlinedescribe">{{item.describe}}</view>
  19. <view class="itemCklineBox" v-show="item.keyType==1">
  20. <view class="itemCkline" :class="{itemckActive:name.check}" @click="itemXx(name)" v-for="(name,nameIndex) in item.array">{{name.name}}</view>
  21. <!-- <view class="itemCkline itemckActive">张杰</view> -->
  22. </view>
  23. <view class="textareaBox" v-show="item.keyType==2">
  24. <textarea placeholder-style="color:#CCCCCC" placeholder="请输入~" v-model="item.itemValue" class="textareaCont"/>
  25. </view>
  26. <view class="imgBox" v-show="item.keyType==3">
  27. <view class="imgLine" v-for="(img,imgindex) in item.imgArr">
  28. <image :class="{img4:(imgindex+1)%4==0}" :src="img" mode="" class="itemImg"></image>
  29. <image src="../../static/img/icon_delpic@2x.png" mode="" class="delImg"></image>
  30. </view>
  31. <view class="imgLine" @click="uploadImg(item)">
  32. <image src="../../static/img/icon_addpic@2x.png" mode="" class="itemImg"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view style="height: 160rpx;"></view>
  38. <view class="bottom">
  39. <view class="bottomBtn" @click="sub">保存</view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. pickerindex:null,
  48. array:[0,1,2,3,4,5],
  49. index1:'',
  50. index2:'',
  51. categoryList:'',
  52. pickerItem:'',
  53. }
  54. },
  55. onLoad(opt) {
  56. var name = opt.name;
  57. uni.setNavigationBarTitle({
  58. title: name
  59. })
  60. this.index1=opt.index1;
  61. this.index2=opt.index2;
  62. console.log(this.$store.state.categoryList)
  63. this.categoryList=this.$store.state.categoryList;
  64. this.categoryList[this.index1].sectionList.forEach(v=>{
  65. console.log(v)
  66. if(v.check){
  67. }else{
  68. v.itemList.forEach((item,index)=>{
  69. item.itemValue='';
  70. if(item.keyType==4){
  71. var arr=[];
  72. for(var i=0;i<Number(item.keyValue) +1;i++){
  73. arr.push(i)
  74. }
  75. item.array=arr;
  76. item.storeIndex=null;
  77. item.itemValue=null;
  78. }else if(item.keyType==1){
  79. item.keyValue=item.keyValue.replace(/,/ig,',')
  80. var array= item.keyValue.split(",")
  81. var arr=[]
  82. array.forEach(name=>{
  83. var obj={
  84. name:name,
  85. check:false
  86. }
  87. arr.push(obj)
  88. })
  89. item.array=arr
  90. }else if(item.keyType==3){
  91. item.imgArr=[]
  92. }
  93. })
  94. }
  95. })
  96. /* this.categoryList[this.index1].sectionList[this.index2].itemList.forEach((item,index)=>{
  97. item.itemValue='';
  98. if(item.keyType==4){
  99. var arr=[];
  100. for(var i=0;i<Number(item.keyValue) +1;i++){
  101. arr.push(i)
  102. }
  103. item.array=arr;
  104. item.storeIndex=null;
  105. item.itemValue=null;
  106. }else if(item.keyType==1){
  107. item.keyValue=item.keyValue.replace(/,/ig,',')
  108. var array= item.keyValue.split(",")
  109. var arr=[]
  110. array.forEach(name=>{
  111. var obj={
  112. name:name,
  113. check:false
  114. }
  115. arr.push(obj)
  116. })
  117. item.array=arr
  118. }else if(item.keyType==3){
  119. item.imgArr=[]
  120. }
  121. }) */
  122. console.log(this.categoryList);
  123. },
  124. methods: {
  125. bindPickerChange(e){
  126. console.log(e)
  127. this.pickerItem.itemValue=e.detail.value;
  128. console.log(this.categoryList);
  129. this.categoryList.splice(1,0)
  130. },
  131. pickerClick(item){
  132. this.pickerItem=item
  133. },
  134. itemXx(name){
  135. console.log(name)
  136. name.check=!name.check;
  137. this.categoryList.splice(1,0)
  138. },
  139. uploadImg(item){
  140. var that=this;
  141. console.log(item)
  142. var length=item.imgArr.length;
  143. if(length==10){
  144. uni.showToast({
  145. title: '最多上传10张',
  146. icon:'none',
  147. duration: 2000,
  148. });
  149. return false;
  150. }
  151. var num=10-length;
  152. uni.chooseImage({
  153. sourceType: ['album'],
  154. count:num,
  155. success: (chooseImageRes) => {
  156. const tempFilePaths = chooseImageRes.tempFilePaths;
  157. uni.uploadFile({
  158. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  159. filePath: tempFilePaths[0],
  160. name: 'file',
  161. formData: {
  162. 'user': 'test'
  163. },
  164. success: (uploadFileRes) => {
  165. console.log(JSON.parse(uploadFileRes.data).data );
  166. item.imgArr=item.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  167. that.categoryList.splice(1,0)
  168. }
  169. });
  170. /* that.$http('accompany/SuperCheckSheet/uploadFile', tempFilePaths[0], 'POST').then(res => {
  171. }) */
  172. }
  173. });
  174. },
  175. sub(){
  176. console.log(this.categoryList);
  177. var go=true;
  178. this.categoryList[this.index1].sectionList[this.index2].itemList.forEach(item=>{
  179. if(item.keyType==3){
  180. item.itemValue=item.imgArr.join(',');
  181. console.log(item.itemValue)
  182. }else if(item.keyType==1){
  183. var arr=[]
  184. item.array.forEach(name=>{
  185. if(name.check){
  186. arr.push(name.name)
  187. }
  188. })
  189. item.itemValue=arr.join(',');
  190. }
  191. if(item.itemValue==0){
  192. }else if(item.itemValue==''){
  193. go=false
  194. }
  195. })
  196. console.log(this.categoryList[this.index1].sectionList[this.index2].itemList)
  197. if(!go){
  198. uni.showToast({
  199. title: '每一项都是必填,请填写完成',
  200. icon:'none',
  201. duration: 3000,
  202. });
  203. return false;
  204. }
  205. this.categoryList[this.index1].sectionList[this.index2].check=true;
  206. uni.navigateBack({
  207. delta:1
  208. })
  209. this.$store.commit('mutationsCategoryList',this.categoryList)
  210. }
  211. }
  212. }
  213. </script>
  214. <style scoped>
  215. .content{
  216. background: #F4F5F7;
  217. min-height: 100vh;
  218. }
  219. /* #ifdef H5 */
  220. .content{
  221. background: #F4F5F7;
  222. min-height:calc(100vh - 44px);
  223. }
  224. /* #endif */
  225. .boxLine{
  226. padding: 30rpx 20rpx;
  227. background: #FFFFFF;
  228. border-bottom: 1px solid #EEEEEE;
  229. }
  230. .boxLineTop{
  231. display: flex;
  232. justify-content: space-between;
  233. }
  234. .store{
  235. color: #FF4F00;font-size: 30rpx;
  236. }
  237. .storeJtimg{
  238. width: 14rpx;
  239. height: 26rpx;
  240. margin-top: 8rpx;
  241. margin-left: 10rpx;
  242. }
  243. .store{
  244. display: flex;
  245. }
  246. .itemName{
  247. color: #3C3C3C;font-size: 30rpx;font-weight: 600;
  248. }
  249. .boxlinedescribe{
  250. color: #999999;
  251. font-size: 26rpx;
  252. padding-top: 10rpx;
  253. }
  254. .itemCklineBox{
  255. display: flex;
  256. flex-wrap: wrap;
  257. padding-top: 20rpx;
  258. }
  259. .itemCkline{
  260. height: 56rpx;
  261. background: #F4F5F7;
  262. border-radius: 28rpx;
  263. line-height: 56rpx;
  264. padding: 0 40rpx;
  265. font-size: 28rpx;
  266. color: #333333;
  267. margin-right: 30rpx;
  268. }
  269. .itemckActive{
  270. background: #FF4F00;color: #FFFFFF;
  271. }
  272. .textareaCont{
  273. width: 670rpx;
  274. height: 120rpx;
  275. background: #F4F5F7;
  276. border-radius: 10rpx;
  277. padding: 28rpx 20rpx;
  278. font-size: 28rpx;
  279. color: #3C3C3C;
  280. }
  281. .textareaBox{
  282. padding-top: 20rpx;
  283. }
  284. .imgBox{
  285. padding-top: 20rpx;
  286. display: flex;
  287. flex-wrap: wrap;
  288. }
  289. .itemImg{
  290. width:150rpx;
  291. height: 150rpx;
  292. margin-right: 35rpx;
  293. margin-top: 30rpx;
  294. }
  295. .img4{
  296. margin-right: 0;
  297. }
  298. .delImg{
  299. width: 32rpx;
  300. height: 32rpx;
  301. position: absolute;
  302. left: 135rpx;
  303. top: 10rpx;
  304. }
  305. .imgLine{
  306. position: relative;
  307. }
  308. .bottom{
  309. width: 750rpx;
  310. height: 120rpx;
  311. background: #FFFFFF;
  312. box-shadow: 0px -4px 8px 0px rgba(153,153,153,0.08);
  313. position: fixed;
  314. left: 0;
  315. bottom: 0;
  316. }
  317. .bottomBtn{
  318. width: 702rpx;
  319. height: 74rpx;
  320. background: linear-gradient(124deg, #FF8700 0%, #FF4F00 100%);
  321. border-radius: 37rpx;
  322. text-align: center;
  323. line-height: 74rpx;
  324. color: #FFFFFF;
  325. font-size:30rpx;
  326. margin-top: 24rpx;
  327. margin-left: 24rpx;
  328. }
  329. </style>