input2.vue 10 KB

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