input2.vue 8.9 KB

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