input2.vue 11 KB

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