input2.vue 11 KB

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