input2.vue 10 KB

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