input2.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <view class="topBox">
  4. <view>
  5. <u-icon name="error-circle-fill" color="#FF3B30" size="28"></u-icon>
  6. <text style="color: #FF3B30;margin-left: 10rpx;">学习前请提交完整审核资料</text>
  7. </view>
  8. <view style="color: #007AFF;">稍后再填</view>
  9. </view>
  10. <view class="bodyBox" style="margin-top: 30rpx;padding:0 20rpx;">
  11. <u-form :model="form" ref="uForm">
  12. <template v-for="(item, index) in listData">
  13. <u-form-item
  14. v-if="item.inputType == 4"
  15. :key="index"
  16. :label="item.fieldName"
  17. :required="item.required"
  18. :label-width="auto"
  19. :prop="item.required ? item.fieldKey : ''"
  20. label-position="top"
  21. >
  22. <text style="color: blue;position: absolute;top: 20rpx;left: 180rpx;text-decoration: underline;" @click="downDocx(item.url)">点击下载</text>
  23. <view class="dis_stys"><text style="color: #999999;">下载承诺书进行填写并签名盖章后上传(≤2M)</text></view>
  24. <image v-if="!form[item.fieldKey]" style="width: 169rpx; height: 169rpx;" @click="uploadFieds" src="@/static/info_4.png"></image>
  25. <view class="quzw" v-if="form[item.fieldKey]">
  26. <view v-if="form[item.fieldKey].split('.').splice(-1)[0] == 'docx' || form[item.fieldKey].split('.').splice(-1)[0] == 'doc'" class="borsrs">
  27. <image src="@/static/icon/jy_icon.png" style="width: 168rpx; height: 168rpx;"></image>
  28. <text>{{ titleName }}</text>
  29. </view>
  30. <image v-else :src="form[item.fieldKey]" style="width: 100%; height: 100%;" mode="aspectFit" @click="seePhotos(form[item.fieldKey])"></image>
  31. <u-icon name="close-circle-fill" color="red" size="44" class="optionsAbs" @click="clearWord"></u-icon>
  32. </view>
  33. </u-form-item>
  34. </template>
  35. </u-form>
  36. </view>
  37. <view @click="submits" class="submit_btn">提交资料</view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. form: {
  45. commitment_seal: ''
  46. },
  47. goodsId: null,
  48. fileList1: [],
  49. listData: {}, //页面数据
  50. openVerify: false, // 控制是否手动验证
  51. nextStatus: false, //是否有下一步
  52. copyData: null,
  53. titleName: '文件名称居中对齐过长换行', //word名称
  54. rules: {
  55. commitment_seal: [
  56. {
  57. required: true,
  58. message: '请上传承诺书盖章',
  59. trigger: ['change', 'blur']
  60. }
  61. ]
  62. }
  63. };
  64. },
  65. created() {},
  66. onLoad(option) {
  67. this.goodsId = Number(option.id);
  68. this.getInfo();
  69. },
  70. onReady() {
  71. this.$refs.uForm.setRules(this.rules);
  72. },
  73. methods: {
  74. seePhotos(url) {
  75. uni.previewImage({
  76. urls: [url]
  77. });
  78. },
  79. downDocx(url) {
  80. uni.downloadFile({
  81. url: this.$method.splitImgHost(url),
  82. success: res => {
  83. if (res.statusCode === 200) {
  84. console.log(this.$method.splitImgHost(url));
  85. this.$method.showToast('下载成功');
  86. }
  87. }
  88. });
  89. },
  90. clearWord() {
  91. this.$set(this.form, 'commitment_seal', '');
  92. this.titleName = '';
  93. },
  94. uploadFieds() {
  95. var self = this;
  96. wx.chooseMessageFile({
  97. count: 1,
  98. size: 2097152,
  99. type: 'file',
  100. success(res) {
  101. if (res.tempFiles[0].size > 2097152) {
  102. self.$method.showToast('上传文件不得大于2M');
  103. return;
  104. } else {
  105. var type = res.tempFiles[0].path.split('.').splice(-1);
  106. if (type[0] != 'jpg' && type[0] != 'png' && type[0] != 'jpeg' && type[0] != 'docx' && type[0] != 'doc') {
  107. self.$method.showToast('请上传word文档或图片');
  108. return;
  109. }
  110. self.titleName = res.tempFiles[0].name;
  111. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  112. self.$nextTick(function() {
  113. this.resultForm();
  114. });
  115. }
  116. }
  117. });
  118. },
  119. //提交表单
  120. async submitApi() {
  121. var data = JSON.parse(JSON.stringify(this.form));
  122. if (data['commitment_seal']) {
  123. console.log(123);
  124. data.commitment_seal = await this.$method.uploadFile(data.commitment_seal, 0);
  125. } else {
  126. console.log(456);
  127. }
  128. var concatData = {};
  129. Object.assign(concatData, this.copyData, data);
  130. console.log(concatData);
  131. },
  132. //验证表单
  133. resultForm(int) {
  134. if (this.openVerify) {
  135. for (let i = 0; i < this.listData.length; i++) {
  136. if (this.listData[i].fieldKey === 'commitment_seal' && !this.listData[i].required) {
  137. this.submitApi();
  138. return;
  139. }
  140. }
  141. this.$refs.uForm.validate(valid => {
  142. if (valid) {
  143. if (int === 1) {
  144. this.submitApi();
  145. }
  146. } else {
  147. console.log('验证失败');
  148. }
  149. });
  150. }
  151. },
  152. submits() {
  153. this.openVerify = true;
  154. this.resultForm(1);
  155. },
  156. async changePhotoListHeader1(lists, name) {
  157. if (lists.length) {
  158. this.fileList1 = lists;
  159. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  160. } else {
  161. this.fileList1 = [];
  162. this.$set(this.form, 'commitment_seal', '');
  163. }
  164. this.$nextTick(function() {
  165. this.resultForm();
  166. });
  167. },
  168. getInfo() {
  169. // this.copyData = this.$store.getters.getCopyData
  170. this.copyData = {
  171. name: '唐立安',
  172. sex: '男'
  173. };
  174. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  175. var ast = JSON.parse(res.data.data.keyValue2);
  176. this.listData = ast;
  177. });
  178. }
  179. }
  180. };
  181. </script>
  182. <style>
  183. page {
  184. background: #eaeef1;
  185. }
  186. </style>
  187. <style scope>
  188. .quzw {
  189. width: 638rpx;
  190. height: 638rpx;
  191. position: relative;
  192. border: 2rpx solid #eee;
  193. border-radius: 8rpx;
  194. }
  195. .borsrs {
  196. width: 640rpx;
  197. height: 640rpx;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. justify-content: center;
  202. }
  203. .optionsAbs {
  204. position: absolute;
  205. z-index: 99;
  206. top: 10rpx;
  207. right: 10rpx;
  208. }
  209. .dis_stys {
  210. display: flex;
  211. align-items: center;
  212. justify-content: space-between;
  213. }
  214. .handCenter {
  215. background: #f7f7f7;
  216. border: 2rpx solid #eeeeee;
  217. border-radius: 24rpx;
  218. }
  219. .headerSDels {
  220. height: 58rpx;
  221. padding: 0rpx 24rpx;
  222. font-weight: bold;
  223. display: flex;
  224. align-items: center;
  225. flex-direction: row-reverse;
  226. }
  227. .listBox {
  228. margin: 24rpx 32rpx 0rpx;
  229. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  230. border-radius: 32rpx;
  231. background-color: #fff;
  232. overflow: hidden;
  233. }
  234. .imgBoxs {
  235. width: 156rpx;
  236. height: 203rpx;
  237. }
  238. .imgBoxs2 {
  239. width: 171rpx;
  240. height: 108rpx;
  241. }
  242. .submit_btn {
  243. width: 526rpx;
  244. height: 80rpx;
  245. background: #007aff;
  246. border-radius: 40rpx;
  247. text-align: center;
  248. line-height: 80rpx;
  249. color: #ffffff;
  250. margin: 30rpx auto;
  251. }
  252. .picker {
  253. text-align: right;
  254. }
  255. input {
  256. text-align: right;
  257. }
  258. .bodyBox {
  259. background: #ffffff;
  260. border-radius: 24rpx;
  261. width: 100%;
  262. }
  263. .topBox {
  264. height: 80rpx;
  265. background: #ffffff;
  266. border-radius: 24rpx;
  267. width: 100%;
  268. display: flex;
  269. justify-content: space-between;
  270. line-height: 80rpx;
  271. padding: 0 20rpx;
  272. font-size: 24rpx;
  273. }
  274. </style>