input2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view style="padding: 30rpx;">
  3. <nav-bar title="填写审核资料"></nav-bar>
  4. <view class="topBox">
  5. <view>
  6. <u-icon name="error-circle-fill" color="#FF3B30" size="28"></u-icon>
  7. <text style="color: #FF3B30;margin-left: 10rpx;">学习前请提交完整审核资料</text>
  8. </view>
  9. <view style="color: #007AFF;" @click="backPage">稍后再填</view>
  10. </view>
  11. <u-collapse v-if="remarkStatus" :item-style="itemStyle" event-type="close">
  12. <u-collapse-item title="审核结果反馈">
  13. <view style="padding-bottom: 30rpx;">
  14. <text class="collapse-item">{{ remark }}</text>
  15. </view>
  16. </u-collapse-item>
  17. </u-collapse>
  18. <view class="bodyBox" style="margin-top: 30rpx;padding:0 20rpx;">
  19. <u-form :model="form" ref="uForm">
  20. <template v-for="(item, index) in listData">
  21. <u-form-item
  22. v-if="item.inputType == 4"
  23. :key="index"
  24. :label="item.fieldName"
  25. :required="item.required"
  26. :label-width="auto"
  27. :prop="item.required ? item.fieldKey : ''"
  28. label-position="top"
  29. >
  30. <text style="color: #007AFF;position: absolute;top: 20rpx;left: 180rpx;text-decoration: underline;" @click="downDocx(item.url)">点击下载</text>
  31. <view class="dis_stys"><text style="color: #999999;">下载承诺书进行填写并签名盖章后上传(≤2M)</text></view>
  32. <image v-if="!form[item.fieldKey]" style="width: 169rpx; height: 169rpx;" @click="getChast" src="@/static/info_4.png"></image>
  33. <view class="quzw" v-if="form[item.fieldKey]">
  34. <view v-if="form[item.fieldKey].split('.').splice(-1)[0] == 'docx' || form[item.fieldKey].split('.').splice(-1)[0] == 'doc'" class="borsrs">
  35. <image src="@/static/icon/jy_icon.png" style="width: 168rpx; height: 168rpx;"></image>
  36. <text>{{ titleName }}</text>
  37. </view>
  38. <image v-else :src="form[item.fieldKey]" style="width: 100%; height: 100%;" mode="aspectFit" @click="seePhotos(form[item.fieldKey])"></image>
  39. <u-icon name="close-circle-fill" color="red" size="44" class="optionsAbs" @click="clearWord"></u-icon>
  40. </view>
  41. </u-form-item>
  42. </template>
  43. </u-form>
  44. </view>
  45. <view @click="submits" class="submit_btn">提交资料</view>
  46. <u-action-sheet :list="list" v-model="showTableDown" @click="clickIndex"></u-action-sheet>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. showTableDown: false,
  54. list: [
  55. {
  56. text: '上传图片'
  57. },
  58. // {
  59. // text: '上传文件'
  60. // }
  61. ],
  62. isUploading:false,
  63. itemStyle: {
  64. marginTop: '20px',
  65. backgroundColor: '#fff',
  66. borderRadius: '24rpx',
  67. padding: '0rpx 20rpx'
  68. },
  69. form: {
  70. commitment_seal: ''
  71. },
  72. goodsId: null,
  73. fileList1: [],
  74. id: null, //id有值的话就是修改页面
  75. listData: {}, //页面数据
  76. openVerify: false, // 控制是否手动验证
  77. nextStatus: false, //是否有下一步
  78. titleName: '文件名称居中对齐过长换行', //word名称
  79. remark: '', //反馈文本
  80. remarkStatus: false, //是否存在审核结果反馈
  81. rules: {
  82. commitment_seal: [
  83. {
  84. required: true,
  85. message: '请上传承诺书盖章',
  86. trigger: ['change', 'blur']
  87. }
  88. ]
  89. },
  90. orderGoodsId:0
  91. };
  92. },
  93. created() {},
  94. onLoad(option) {
  95. this.orderGoodsId = Number(option.orderGoodsId)
  96. this.goodsId = Number(option.id);
  97. this.getInfo();
  98. },
  99. onReady() {
  100. this.$refs.uForm.setRules(this.rules);
  101. },
  102. methods: {
  103. backPage() {
  104. uni.navigateBack();
  105. },
  106. seePhotos(url) {
  107. uni.previewImage({
  108. urls: [url]
  109. });
  110. },
  111. downDocx(url) {
  112. this.$api.addWordbaseprofileStamp({ goodsId: this.goodsId }).then(res => {
  113. uni.downloadFile({
  114. url: this.$method.splitImgHost(res.data.msg),
  115. success: result => {
  116. if (result.statusCode === 200) {
  117. const filePath = result.tempFilePath
  118. console.log(this.$method.splitImgHost(res.data.msg));
  119. this.$method.showToast('下载成功');
  120. uni.saveImageToPhotosAlbum({
  121. filePath: filePath,
  122. success: function (errMsg) {
  123. uni.showToast({
  124. mask: true,
  125. title: '保存成功'
  126. });
  127. },
  128. fail:(errMsg)=>{
  129. uni.showToast({
  130. mask: true,
  131. title: '保存失败'
  132. });
  133. },
  134. complete:(errMsg)=>{
  135. }
  136. });
  137. }
  138. }
  139. });
  140. });
  141. },
  142. clearWord() {
  143. this.$set(this.form, 'commitment_seal', '');
  144. this.titleName = '';
  145. },
  146. clickIndex(inds){
  147. if(inds === 0){
  148. this.uploadImgs()
  149. }
  150. if(inds === 1){
  151. this.uploadFieds()
  152. }
  153. },
  154. getChast(){
  155. this.showTableDown = true;
  156. },
  157. uploadImgs(){
  158. var self = this
  159. uni.chooseImage({
  160. count: 1, //默认9
  161. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  162. success: function (res) {
  163. if (res.tempFiles[0].size > 2097152) {
  164. self.$method.showToast('上传图片不得大于2M');
  165. return;
  166. } else {
  167. var type = res.tempFiles[0].path.split('.').splice(-1);
  168. if (type[0] != 'jpg' && type[0] != 'png' && type[0] != 'jpeg') {
  169. self.$method.showToast('请上传图片格式');
  170. return;
  171. }
  172. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  173. self.$nextTick(function() {
  174. this.resultForm();
  175. });
  176. }
  177. }
  178. });
  179. },
  180. uploadFieds() {
  181. var self = this;
  182. wx.chooseMessageFile({
  183. count: 1,
  184. size: 2097152,
  185. type: 'file',
  186. success(res) {
  187. if (res.tempFiles[0].size > 2097152) {
  188. self.$method.showToast('上传文件不得大于2M');
  189. return;
  190. } else {
  191. var type = res.tempFiles[0].path.split('.').splice(-1);
  192. if (type[0] != 'jpg' && type[0] != 'png' && type[0] != 'jpeg' && type[0] != 'docx' && type[0] != 'doc') {
  193. self.$method.showToast('请上传word文档或图片');
  194. return;
  195. }
  196. self.titleName = res.tempFiles[0].name;
  197. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  198. self.$nextTick(function() {
  199. this.resultForm();
  200. });
  201. }
  202. }
  203. });
  204. },
  205. //提交表单
  206. async submitApi() {
  207. var data = JSON.parse(JSON.stringify(this.form));
  208. if (data['commitment_seal']) {
  209. data.commitment_seal = await this.$method.uploadFile(data.commitment_seal, 0);
  210. }
  211. this.optionChanges(data);
  212. },
  213. optionChanges(data) {
  214. var self = this;
  215. var objs = {};
  216. for (let k in data) {
  217. objs[k] = {
  218. fieldKey: k,
  219. value: data[k],
  220. fieldName: (function() {
  221. for (let i = 0; i < self.listData.length; i++) {
  222. if (self.listData[i].fieldKey == k) {
  223. return self.listData[i].fieldName;
  224. }
  225. }
  226. })(),
  227. status: self.remarkStatus ? 1 : 0
  228. };
  229. }
  230. var datas = {
  231. orderGoodsId:this.orderGoodsId,
  232. goodsId: self.goodsId,
  233. keyValue: JSON.stringify(objs)
  234. };
  235. if (self.remarkStatus) {
  236. datas.id = self.id;
  237. self.$api.editbaseprofileStamp(datas).then(res => {
  238. this.isUploading = false;
  239. if (res.data.code === 200) {
  240. self.$method.showToast('提交成功');
  241. setTimeout(() => {
  242. console.log('延迟')
  243. uni.navigateBack();
  244. }, 1500)
  245. }
  246. });
  247. } else {
  248. self.$api.addbaseprofileStamp(datas).then(res => {
  249. this.isUploading = false;
  250. if (res.data.code === 200) {
  251. self.$method.showToast('提交成功');
  252. setTimeout(() => {
  253. console.log('延迟')
  254. uni.navigateBack();
  255. }, 1500)
  256. }
  257. });
  258. }
  259. },
  260. //验证表单
  261. resultForm(int) {
  262. if (this.openVerify) {
  263. for (let i = 0; i < this.listData.length; i++) {
  264. if (this.listData[i].fieldKey === 'commitment_seal' && !this.listData[i].required) {
  265. this.submitApi();
  266. return;
  267. }
  268. }
  269. this.$refs.uForm.validate(valid => {
  270. if (valid) {
  271. if (int === 1) {
  272. this.submitApi();
  273. }
  274. } else {
  275. this.isUploading = false;
  276. console.log('验证失败');
  277. }
  278. });
  279. }
  280. },
  281. submits() {
  282. if(this.isUploading) {
  283. return;
  284. }
  285. this.isUploading = true;
  286. this.openVerify = true;
  287. this.resultForm(1);
  288. },
  289. async changePhotoListHeader1(lists, name) {
  290. if (lists.length) {
  291. this.fileList1 = lists;
  292. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  293. } else {
  294. this.fileList1 = [];
  295. this.$set(this.form, 'commitment_seal', '');
  296. }
  297. this.$nextTick(function() {
  298. this.resultForm();
  299. });
  300. },
  301. getInfo() {
  302. var self = this;
  303. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  304. var ast = JSON.parse(res.data.data.keyValue2);
  305. self.listData = ast;
  306. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId,orderGoodsId:self.orderGoodsId }).then(result => {
  307. if (result.data.code === 200) {
  308. if (result.data.data && result.data.data.status === 3) {
  309. self.remark = result.data.data.text;
  310. self.remarkStatus = true;
  311. self.id = result.data.data.id;
  312. } else if (result.data.data && (result.data.data.status === 1 || result.data.data.status === 2)) {
  313. uni.showModal({
  314. showCancel: false,
  315. content:
  316. result.data.data.status === 1
  317. ? '该商品审核资料已通过,不可重复提交资料'
  318. : result.data.data.status === 2
  319. ? '该商品审核资料处于待审核状态,不可重复提交资料'
  320. : '请联系管理员',
  321. success: function(k) {
  322. if (k.confirm) {
  323. uni.navigateBack();
  324. }
  325. }
  326. });
  327. }
  328. }
  329. });
  330. });
  331. }
  332. }
  333. };
  334. </script>
  335. <style>
  336. page {
  337. background: #eaeef1;
  338. }
  339. </style>
  340. <style scope>
  341. /deep/ .u-collapse-title {
  342. color: #FF3B30;
  343. font-size: 24rpx;
  344. }
  345. .collapse-item {
  346. color: #666;
  347. font-size: 24rpx;
  348. padding-bottom: 30rpx;
  349. }
  350. .quzw {
  351. width: 638rpx;
  352. height: 638rpx;
  353. position: relative;
  354. border: 2rpx solid #eee;
  355. border-radius: 8rpx;
  356. }
  357. .borsrs {
  358. width: 640rpx;
  359. height: 640rpx;
  360. display: flex;
  361. flex-direction: column;
  362. align-items: center;
  363. justify-content: center;
  364. }
  365. .optionsAbs {
  366. position: absolute;
  367. z-index: 99;
  368. top: 10rpx;
  369. right: 10rpx;
  370. }
  371. .dis_stys {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. }
  376. .handCenter {
  377. background: #f7f7f7;
  378. border: 2rpx solid #eeeeee;
  379. border-radius: 24rpx;
  380. }
  381. .headerSDels {
  382. height: 58rpx;
  383. padding: 0rpx 24rpx;
  384. font-weight: bold;
  385. display: flex;
  386. align-items: center;
  387. flex-direction: row-reverse;
  388. }
  389. .listBox {
  390. margin: 24rpx 32rpx 0rpx;
  391. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  392. border-radius: 32rpx;
  393. background-color: #fff;
  394. overflow: hidden;
  395. }
  396. .imgBoxs {
  397. width: 156rpx;
  398. height: 203rpx;
  399. }
  400. .imgBoxs2 {
  401. width: 171rpx;
  402. height: 108rpx;
  403. }
  404. .submit_btn {
  405. width: 526rpx;
  406. height: 80rpx;
  407. background: #007aff;
  408. border-radius: 40rpx;
  409. text-align: center;
  410. line-height: 80rpx;
  411. color: #ffffff;
  412. margin: 30rpx auto;
  413. }
  414. .picker {
  415. text-align: right;
  416. }
  417. input {
  418. text-align: right;
  419. }
  420. .bodyBox {
  421. background: #ffffff;
  422. border-radius: 24rpx;
  423. width: 100%;
  424. }
  425. .topBox {
  426. height: 80rpx;
  427. background: #ffffff;
  428. border-radius: 24rpx;
  429. width: 100%;
  430. display: flex;
  431. justify-content: space-between;
  432. line-height: 80rpx;
  433. padding: 0 20rpx;
  434. font-size: 24rpx;
  435. }
  436. </style>