input2.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. };
  91. },
  92. created() {},
  93. onLoad(option) {
  94. this.goodsId = Number(option.id);
  95. this.getInfo();
  96. },
  97. onReady() {
  98. this.$refs.uForm.setRules(this.rules);
  99. },
  100. methods: {
  101. backPage() {
  102. uni.navigateBack();
  103. },
  104. seePhotos(url) {
  105. uni.previewImage({
  106. urls: [url]
  107. });
  108. },
  109. downDocx(url) {
  110. this.$api.addWordbaseprofileStamp({ goodsId: this.goodsId }).then(res => {
  111. uni.downloadFile({
  112. url: this.$method.splitImgHost(res.data.msg),
  113. success: result => {
  114. if (result.statusCode === 200) {
  115. const filePath = result.tempFilePath
  116. console.log(this.$method.splitImgHost(res.data.msg));
  117. this.$method.showToast('下载成功');
  118. uni.saveImageToPhotosAlbum({
  119. filePath: filePath,
  120. success: function (errMsg) {
  121. uni.showToast({
  122. mask: true,
  123. title: '保存成功'
  124. });
  125. },
  126. fail:(errMsg)=>{
  127. uni.showToast({
  128. mask: true,
  129. title: '保存失败'
  130. });
  131. },
  132. complete:(errMsg)=>{
  133. }
  134. });
  135. }
  136. }
  137. });
  138. });
  139. },
  140. clearWord() {
  141. this.$set(this.form, 'commitment_seal', '');
  142. this.titleName = '';
  143. },
  144. clickIndex(inds){
  145. if(inds === 0){
  146. this.uploadImgs()
  147. }
  148. if(inds === 1){
  149. this.uploadFieds()
  150. }
  151. },
  152. getChast(){
  153. this.showTableDown = true;
  154. },
  155. uploadImgs(){
  156. var self = this
  157. uni.chooseImage({
  158. count: 1, //默认9
  159. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  160. success: function (res) {
  161. if (res.tempFiles[0].size > 2097152) {
  162. self.$method.showToast('上传图片不得大于2M');
  163. return;
  164. } else {
  165. var type = res.tempFiles[0].path.split('.').splice(-1);
  166. if (type[0] != 'jpg' && type[0] != 'png' && type[0] != 'jpeg') {
  167. self.$method.showToast('请上传图片格式');
  168. return;
  169. }
  170. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  171. self.$nextTick(function() {
  172. this.resultForm();
  173. });
  174. }
  175. }
  176. });
  177. },
  178. uploadFieds() {
  179. var self = this;
  180. wx.chooseMessageFile({
  181. count: 1,
  182. size: 2097152,
  183. type: 'file',
  184. success(res) {
  185. if (res.tempFiles[0].size > 2097152) {
  186. self.$method.showToast('上传文件不得大于2M');
  187. return;
  188. } else {
  189. var type = res.tempFiles[0].path.split('.').splice(-1);
  190. if (type[0] != 'jpg' && type[0] != 'png' && type[0] != 'jpeg' && type[0] != 'docx' && type[0] != 'doc') {
  191. self.$method.showToast('请上传word文档或图片');
  192. return;
  193. }
  194. self.titleName = res.tempFiles[0].name;
  195. self.$set(self.form, 'commitment_seal', res.tempFiles[0].path);
  196. self.$nextTick(function() {
  197. this.resultForm();
  198. });
  199. }
  200. }
  201. });
  202. },
  203. //提交表单
  204. async submitApi() {
  205. var data = JSON.parse(JSON.stringify(this.form));
  206. if (data['commitment_seal']) {
  207. data.commitment_seal = await this.$method.uploadFile(data.commitment_seal, 0);
  208. }
  209. this.optionChanges(data);
  210. },
  211. optionChanges(data) {
  212. var self = this;
  213. var objs = {};
  214. for (let k in data) {
  215. objs[k] = {
  216. fieldKey: k,
  217. value: data[k],
  218. fieldName: (function() {
  219. for (let i = 0; i < self.listData.length; i++) {
  220. if (self.listData[i].fieldKey == k) {
  221. return self.listData[i].fieldName;
  222. }
  223. }
  224. })(),
  225. status: self.remarkStatus ? 1 : 0
  226. };
  227. }
  228. var datas = {
  229. goodsId: self.goodsId,
  230. keyValue: JSON.stringify(objs)
  231. };
  232. if (self.remarkStatus) {
  233. datas.id = self.id;
  234. if(this.isUploading) {
  235. return;
  236. }
  237. this.isUploading = true;
  238. self.$api.editbaseprofileStamp(datas).then(res => {
  239. this.isUploading = false;
  240. if (res.data.code === 200) {
  241. self.$method.showToast('提交成功');
  242. uni.navigateBack();
  243. }
  244. });
  245. } else {
  246. if(this.isUploading) {
  247. return;
  248. }
  249. this.isUploading = true;
  250. self.$api.addbaseprofileStamp(datas).then(res => {
  251. this.isUploading = false;
  252. if (res.data.code === 200) {
  253. self.$method.showToast('提交成功');
  254. uni.navigateBack();
  255. }
  256. });
  257. }
  258. },
  259. //验证表单
  260. resultForm(int) {
  261. if (this.openVerify) {
  262. for (let i = 0; i < this.listData.length; i++) {
  263. if (this.listData[i].fieldKey === 'commitment_seal' && !this.listData[i].required) {
  264. this.submitApi();
  265. return;
  266. }
  267. }
  268. this.$refs.uForm.validate(valid => {
  269. if (valid) {
  270. if (int === 1) {
  271. this.submitApi();
  272. }
  273. } else {
  274. console.log('验证失败');
  275. }
  276. });
  277. }
  278. },
  279. submits() {
  280. this.openVerify = true;
  281. this.resultForm(1);
  282. },
  283. async changePhotoListHeader1(lists, name) {
  284. if (lists.length) {
  285. this.fileList1 = lists;
  286. this.form.commitment_seal = await this.$method.imageInfos(lists[0].url);
  287. } else {
  288. this.fileList1 = [];
  289. this.$set(this.form, 'commitment_seal', '');
  290. }
  291. this.$nextTick(function() {
  292. this.resultForm();
  293. });
  294. },
  295. getInfo() {
  296. var self = this;
  297. this.$api.getbaseprofiletpId(this.goodsId).then(res => {
  298. var ast = JSON.parse(res.data.data.keyValue2);
  299. self.listData = ast;
  300. self.$api.getbaseprofileStampgetInfo({ goodsId: self.goodsId }).then(result => {
  301. if (result.data.code === 200) {
  302. if (result.data.data && result.data.data.status === 3) {
  303. self.remark = result.data.data.text;
  304. self.remarkStatus = true;
  305. self.id = result.data.data.id;
  306. } else if (result.data.data && (result.data.data.status === 1 || result.data.data.status === 2)) {
  307. uni.showModal({
  308. showCancel: false,
  309. content:
  310. result.data.data.status === 1
  311. ? '该商品审核资料已通过,不可重复提交资料'
  312. : result.data.data.status === 2
  313. ? '该商品审核资料处于待审核状态,不可重复提交资料'
  314. : '请联系管理员',
  315. success: function(k) {
  316. if (k.confirm) {
  317. uni.navigateBack();
  318. }
  319. }
  320. });
  321. }
  322. }
  323. });
  324. });
  325. }
  326. }
  327. };
  328. </script>
  329. <style>
  330. page {
  331. background: #eaeef1;
  332. }
  333. </style>
  334. <style scope>
  335. /deep/ .u-collapse-title {
  336. color: #FF3B30;
  337. font-size: 24rpx;
  338. }
  339. .collapse-item {
  340. color: #666;
  341. font-size: 24rpx;
  342. padding-bottom: 30rpx;
  343. }
  344. .quzw {
  345. width: 638rpx;
  346. height: 638rpx;
  347. position: relative;
  348. border: 2rpx solid #eee;
  349. border-radius: 8rpx;
  350. }
  351. .borsrs {
  352. width: 640rpx;
  353. height: 640rpx;
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. justify-content: center;
  358. }
  359. .optionsAbs {
  360. position: absolute;
  361. z-index: 99;
  362. top: 10rpx;
  363. right: 10rpx;
  364. }
  365. .dis_stys {
  366. display: flex;
  367. align-items: center;
  368. justify-content: space-between;
  369. }
  370. .handCenter {
  371. background: #f7f7f7;
  372. border: 2rpx solid #eeeeee;
  373. border-radius: 24rpx;
  374. }
  375. .headerSDels {
  376. height: 58rpx;
  377. padding: 0rpx 24rpx;
  378. font-weight: bold;
  379. display: flex;
  380. align-items: center;
  381. flex-direction: row-reverse;
  382. }
  383. .listBox {
  384. margin: 24rpx 32rpx 0rpx;
  385. box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(145, 156, 178, 0.1);
  386. border-radius: 32rpx;
  387. background-color: #fff;
  388. overflow: hidden;
  389. }
  390. .imgBoxs {
  391. width: 156rpx;
  392. height: 203rpx;
  393. }
  394. .imgBoxs2 {
  395. width: 171rpx;
  396. height: 108rpx;
  397. }
  398. .submit_btn {
  399. width: 526rpx;
  400. height: 80rpx;
  401. background: #007aff;
  402. border-radius: 40rpx;
  403. text-align: center;
  404. line-height: 80rpx;
  405. color: #ffffff;
  406. margin: 30rpx auto;
  407. }
  408. .picker {
  409. text-align: right;
  410. }
  411. input {
  412. text-align: right;
  413. }
  414. .bodyBox {
  415. background: #ffffff;
  416. border-radius: 24rpx;
  417. width: 100%;
  418. }
  419. .topBox {
  420. height: 80rpx;
  421. background: #ffffff;
  422. border-radius: 24rpx;
  423. width: 100%;
  424. display: flex;
  425. justify-content: space-between;
  426. line-height: 80rpx;
  427. padding: 0 20rpx;
  428. font-size: 24rpx;
  429. }
  430. </style>