input2.vue 11 KB

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