SupplierEntryForm.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <view class="bg">
  3. <view class="scrollview">
  4. <u--form :rules="rules" labelPosition="left" :model="form" ref="uForm">
  5. <view class="formItemTitle">基本信息(必填)</view>
  6. <u-form-item class="formItem" prop="name" :labelWidth="labelWidth" label="供应商名称" borderBottom >
  7. <u--input :input-align="inputaligh" placeholder="填写供应商名称" v-model="form.name" border="none" clearable ></u--input>
  8. </u-form-item>
  9. <u-form-item class="formItem" prop="city" :labelWidth="labelWidth" label="供应商所在地" borderBottom >
  10. <view class="selectInput">
  11. <u--input @click="cityShow=true" :disabled="true" :input-align="inputaligh" placeholder="选择所在地区" v-model="form.cityName" border="none" ></u--input>
  12. <view @click="cityShow=true"><u-icon name="arrow-right"></u-icon></view>
  13. </view>
  14. </u-form-item>
  15. <u-form-item class="formItem" prop="address" :labelWidth="labelWidth" label="详细地址" borderBottom >
  16. <u--input :input-align="inputaligh" placeholder="填写详细地址" v-model="form.address" border="none" clearable ></u--input>
  17. </u-form-item>
  18. <view class="margin20"></view>
  19. <u-form-item class="formItem" prop="category" :labelWidth="labelWidth" label="主营类目" borderBottom >
  20. <view class="selectInput">
  21. <u--input @click="categoryShow=true" :disabled="true" :input-align="inputaligh" placeholder="主营类目" v-model="form.categoryName" border="none" clearable ></u--input>
  22. <view @click="categoryShow=true"><u-icon name="arrow-right"></u-icon></view>
  23. </view>
  24. </u-form-item>
  25. <view class="margin20"></view>
  26. <u-form-item class="formItem" prop="businessLicenseName" :labelWidth="labelWidth" label="营业注册名称" borderBottom >
  27. <u--input :input-align="inputaligh" placeholder="填写营业执照上企业名称" v-model="form.businessLicenseName" border="none" clearable ></u--input>
  28. </u-form-item>
  29. <u-form-item class="formItem" prop="businessLicenseNo" :labelWidth="labelWidth" label="营业执照号" borderBottom >
  30. <u--input :input-align="inputaligh" placeholder="请填写营业执照注册号" v-model="form.businessLicenseNo" border="none" clearable ></u--input>
  31. </u-form-item>
  32. <u-form-item class="formItem" prop="businessLicense" :labelWidth="labelWidth" label="营业执照照片" borderBottom >
  33. <view class="selectInput">
  34. <u-upload
  35. :fileList="fileList1"
  36. @afterRead="afterRead"
  37. @delete="deletePic"
  38. name="1"
  39. multiple
  40. :maxCount="1"
  41. ></u-upload>
  42. <view style="color: #0084ff;font-size: 28rpx;" @click="openPopup(1)">查看示例</view>
  43. </view>
  44. </u-form-item>
  45. <view class="margin20"></view>
  46. <u-form-item class="formItem" prop="legalPersonName" :labelWidth="labelWidth" label="法人姓名" borderBottom >
  47. <u--input :input-align="inputaligh" placeholder="填写法人姓名" v-model="form.legalPersonName" border="none" clearable ></u--input>
  48. </u-form-item>
  49. <u-form-item class="formItem" prop="legalPersonCardNo" :labelWidth="labelWidth" label="法人身份证号" borderBottom >
  50. <u--input :input-align="inputaligh" placeholder="填写法人身份证号" v-model="form.legalPersonCardNo" border="none" clearable ></u--input>
  51. </u-form-item>
  52. <u-form-item class="formItem" prop="cardNoFront" :labelWidth="labelWidth" label="法人身份证照片 (正面)" borderBottom >
  53. <view class="selectInput">
  54. <u-upload
  55. :fileList="fileList2"
  56. @afterRead="afterRead"
  57. @delete="deletePic"
  58. name="2"
  59. multiple
  60. :maxCount="1"
  61. ></u-upload>
  62. <view style="color: #0084ff;font-size: 28rpx;" @click="openPopup(2)">查看示例</view>
  63. </view>
  64. </u-form-item>
  65. <u-form-item class="formItem" prop="cardNoReverse" :labelWidth="labelWidth" label="法人身份证照片 (反面)" borderBottom >
  66. <view class="selectInput">
  67. <u-upload
  68. :fileList="fileList3"
  69. @afterRead="afterRead"
  70. @delete="deletePic"
  71. name="3"
  72. multiple
  73. :maxCount="1"
  74. ></u-upload>
  75. <view style="color: #0084ff;font-size: 28rpx;" @click="openPopup(3)">查看示例</view>
  76. </view>
  77. </u-form-item>
  78. <view class="margin20"></view>
  79. <u-form-item class="formItem" prop="contact" :labelWidth="labelWidth" label="联系人" borderBottom >
  80. <u--input :input-align="inputaligh" placeholder="输入联系人" v-model="form.contact" border="none" clearable ></u--input>
  81. </u-form-item>
  82. <u-form-item class="formItem" prop="phone" :labelWidth="labelWidth" label="联系电话" borderBottom >
  83. <u--input :input-align="inputaligh" placeholder="输入联系电话" v-model="form.phone" border="none" clearable ></u--input>
  84. </u-form-item>
  85. <u-picker ref="uPicker" @cancel="cityShow=false" keyName="name" :show="cityShow" :columns="cityColumns" @confirm="cityPickerConfirm" @change="citypickerchange"></u-picker>
  86. <u-picker @cancel="categoryShow=false" :show="categoryShow" keyName="dictValue" :columns="categoryColumns" @confirm="categoryPickerConfirm"></u-picker>
  87. </u--form>
  88. <u-popup :closeable='true' :round="10" :show="popupShow" @close="close" @open="open">
  89. <view class="popupView">
  90. <view class="popupImg">
  91. <u--image width="500rpx" height="326rpx" :src="popupImgurl" ></u--image>
  92. </view>
  93. </view>
  94. <view class="popupViewText">
  95. {{ popupText }}
  96. </view>
  97. <view class="w700 btnflex">
  98. <u-button shape="circle" size="medium" type="primary"
  99. @click="close">{{ popupBtn }}</u-button>
  100. </view>
  101. </u-popup>
  102. <view style="height: 100rpx;"></view>
  103. </view>
  104. <view class="btnbox" style="left: 24rpx;">
  105. <!-- <view @click="submit('dosave')" class="btn">
  106. 保存
  107. </view> -->
  108. <view @click="submit('submit')" class="btn2">
  109. 提交审核
  110. </view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import {
  116. getAreaList,myInfo,getCategoryList,settledVendor
  117. } from '@/http/api/common.js'
  118. import env from "@/http/config/config.js"
  119. import {toastFunc} from '@/pages/util/util.js'
  120. export default {
  121. data() {
  122. return {
  123. form:{
  124. "name": "",
  125. "contact": "",
  126. "phone": "",
  127. "businessLicense": "",
  128. "cardNoFront": "",
  129. "cardNoReverse": "",
  130. "address": "",
  131. "city": "",
  132. "cityName": "",
  133. "category": "",
  134. "categoryName": "",
  135. "businessLicenseName": "",
  136. "businessLicenseNo": "",
  137. "legalPersonName": "",
  138. "legalPersonCardNo": ""
  139. },
  140. rules: {
  141. 'name': {
  142. type: 'string',
  143. required: true,
  144. message: '填写供应商名称',
  145. trigger: ['blur', 'change']
  146. },
  147. 'city': {
  148. type: 'string',
  149. required: true,
  150. message: '请选择所在地区',
  151. trigger: ['blur', 'change']
  152. },
  153. 'address': {
  154. type: 'string',
  155. required: true,
  156. message: '请填写详细地址',
  157. trigger: ['blur', 'change']
  158. },
  159. 'category': {
  160. type: 'string',
  161. required: true,
  162. message: '请选择主营类目',
  163. trigger: ['blur', 'change']
  164. },
  165. 'businessLicenseName': {
  166. type: 'string',
  167. required: true,
  168. message: '请填写营业执照上企业名称',
  169. trigger: ['blur', 'change']
  170. },
  171. 'businessLicenseNo': {
  172. type: 'string',
  173. required: true,
  174. message: '请填写营业执照注册号',
  175. trigger: ['blur', 'change']
  176. },
  177. 'businessLicense': {
  178. type: 'string',
  179. required: true,
  180. message: '请上传营业执照照片',
  181. trigger: ['blur', 'change']
  182. },
  183. 'legalPersonName': {
  184. type: 'string',
  185. required: true,
  186. message: '请填写法人姓名',
  187. trigger: ['blur', 'change']
  188. },
  189. 'legalPersonCardNo': {
  190. type: 'string',
  191. required: true,
  192. message: '请填写法人身份证号',
  193. trigger: ['blur', 'change']
  194. },
  195. 'cardNoFront': {
  196. type: 'string',
  197. required: true,
  198. message: '请上传法人身份证照片 (正面)',
  199. trigger: ['blur', 'change']
  200. },
  201. 'cardNoReverse': {
  202. type: 'string',
  203. required: true,
  204. message: '请上传法人身份证照片 (正面)',
  205. trigger: ['blur', 'change']
  206. },
  207. 'contact': {
  208. type: 'string',
  209. required: true,
  210. message: '请输入联系人',
  211. trigger: ['blur', 'change']
  212. },
  213. 'phone':[
  214. {
  215. type: 'string',
  216. required: true,
  217. message: '请输入联系电话',
  218. trigger: ['blur', 'change']
  219. },
  220. {
  221. validator: (rule, value, callback) => {
  222. return uni.$u.test.mobile(value);
  223. },
  224. message: '手机号码格式不正确',
  225. // 触发器可以同时用blur和change
  226. trigger: ['blur'],
  227. }
  228. ]
  229. },
  230. inputaligh:'right',
  231. fileList1:[],
  232. fileList2:[],
  233. fileList3:[],
  234. fileList:[],
  235. file:[],
  236. labelWidth:140,
  237. popupShow:false,
  238. popupText:'',
  239. popupBtn:'上传营业执照',
  240. popupImgurl:'',
  241. cityShow:false,
  242. cityloading:false,
  243. cityColumns: [],
  244. columnData: [],
  245. categoryShow:false,
  246. categoryColumns: [],
  247. showType:'1',
  248. }
  249. },
  250. components: {
  251. },
  252. onLoad(e) {
  253. this.getCategoryList()
  254. this.getAreaList(2)
  255. },
  256. onReady() {
  257. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  258. this.$refs.uForm?.setRules(this.rules)
  259. },
  260. methods: {
  261. async getCategoryList(){
  262. let res = await getCategoryList()
  263. this.categoryColumns.push(res.data.data)
  264. },
  265. //获取城市列表
  266. async getAreaList(level,parentId=''){
  267. let res = await getAreaList({
  268. level,
  269. parentId
  270. })
  271. this.cityColumns.push(res.data.data)
  272. await this.getColumnData(3,res.data.data[0].id)
  273. const picker = this.$refs.uPicker
  274. picker.setColumnValues(1, this.columnData[0])
  275. },
  276. //获取地区列表
  277. async getColumnData(level,parentId=''){
  278. this.cityloading = true
  279. let res = await getAreaList({
  280. level,
  281. parentId
  282. })
  283. this.cityloading = false
  284. this.columnData.push(res.data.data)
  285. },
  286. cityPickerConfirm(e) {
  287. console.log('confirm',e.value)
  288. console.log('city',e.value[1].id)
  289. this.form.city = e.value[1].id
  290. this.form.cityName = e.value[1].name
  291. this.cityShow = false
  292. },
  293. async citypickerchange(e){
  294. const {
  295. columnIndex,
  296. index,
  297. // 微信小程序无法将picker实例传出来,只能通过ref操作
  298. picker = this.$refs.uPicker
  299. } = e
  300. if (columnIndex == 0) {
  301. this.columnData = []
  302. await this.getColumnData(3, this.cityColumns[0][index].id)
  303. picker.setColumnValues(1, this.columnData[0])
  304. }
  305. },
  306. openPopup(type) {
  307. if (type == 1) {
  308. this.popupText = '请参考图示提供营业执照,四角完整,确保证内容文字清晰可见,证件本身无残缺;上传图片要求:支持png、jpg、jpeg格式,1024MB内'
  309. this.popupImgurl = '/static/myinfo/img_yingyezhiz.png'
  310. this.popupBtn = '上传营业执照'
  311. }else if (type == 2) {
  312. this.popupText = '请参考图示提供法人身份证正反面照,四角完整、照片清晰、身份证原件、扫描件或复印件上传图片要求:支持png、jpg、jpeg格式,1024MB内'
  313. this.popupImgurl = '/static/myinfo/img_shenfzzm.png'
  314. this.popupBtn = '上传身份证正面'
  315. }else{
  316. this.popupText = '请参考图示提供法人身份证正反面照,四角完整、照片清晰、身份证原件、扫描件或复印件上传图片要求:支持png、jpg、jpeg格式,1024MB内'
  317. this.popupImgurl = '/static/myinfo/img_shenfzfm.png'
  318. this.popupBtn = '上传身份证反面'
  319. }
  320. this.popupShow = true
  321. // console.log('open');
  322. },
  323. close() {
  324. this.popupShow = false
  325. // console.log('close');
  326. },
  327. categoryPickerConfirm(e) {
  328. console.log('confirm', e.value[0])
  329. this.form.category = e.value[0].dictKey
  330. this.form.categoryName = e.value[0].dictValue
  331. this.categoryShow = false
  332. },
  333. async getmyInfo(){
  334. let res = await myInfo()
  335. if (res.data.code == 200) {
  336. this.form.username = res.data.data.nickName
  337. this.fileList1.push({
  338. url:res.data.data.image
  339. })
  340. }
  341. },
  342. async submit(type){
  343. this.form.businessLicense = this.fileList1[0].url //营业执照
  344. this.form.cardNoFront = this.fileList2[0].url //身份证正面
  345. this.form.cardNoReverse = this.fileList3[0].url //身份证反面
  346. this.$refs.uForm.validate().then(async res1 => {
  347. console.log(res1);
  348. // if (type == 'dosave') {
  349. // //保存
  350. // }else{
  351. // //提交
  352. // }
  353. let res = await settledVendor(this.form)
  354. if (res.data.code == 200) {
  355. uni.navigateTo({
  356. url: '/supplierPages/pages/supplier/supplierSuccess'
  357. });
  358. }
  359. }).catch(errors => {
  360. // uni.$u.toast('校验失败')
  361. })
  362. },
  363. // 删除图片
  364. deletePic(event) {
  365. this[`fileList${event.name}`].splice(event.index, 1)
  366. },
  367. // 新增图片
  368. async afterRead(event) {
  369. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  370. console.log('event',event);
  371. let lists = [].concat(event.file)
  372. let fileListLen = this[`fileList${event.name}`].length
  373. lists.map((item) => {
  374. this[`fileList${event.name}`].push({
  375. ...item,
  376. status: 'uploading',
  377. message: '上传中'
  378. })
  379. })
  380. for (let i = 0; i < lists.length; i++) {
  381. const result = await this.uploadFilePromise(lists[i])
  382. console.log('result',result);
  383. if (result != '') {
  384. let item = this[`fileList${event.name}`][fileListLen]
  385. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  386. status: 'success',
  387. message: '',
  388. url: result
  389. }))
  390. fileListLen++
  391. }else{
  392. toastFunc('上传失败,请删除重试')
  393. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign({}, {
  394. status: 'fail',
  395. message: '',
  396. url: ''
  397. }))
  398. }
  399. }
  400. },
  401. uploadFilePromise(file) {
  402. return new Promise((resolve, reject) => {
  403. let a = uni.uploadFile({
  404. url: env.BASEURL + '/open/upload/uploadFile', // 仅为示例,非真实的接口地址
  405. filePath: file.url,
  406. name: 'file',
  407. success: (res) => {
  408. const fileData = JSON.parse(res.data)
  409. if (fileData.code == 500) {
  410. resolve('')
  411. }else{
  412. const fileData = JSON.parse(res.data)
  413. resolve(fileData.data.fileUrl)
  414. }
  415. }
  416. });
  417. })
  418. },
  419. }
  420. }
  421. </script>
  422. <style lang="scss">
  423. .bg{
  424. width: 750rpx;
  425. height: auto;
  426. border-radius: 0rpx 0rpx 0rpx 0rpx;
  427. display: flex;
  428. flex-direction: column;
  429. align-items: center;
  430. background: #f6f6f6;
  431. }
  432. .scrollview{
  433. width: 100vw;
  434. height: calc(100vh - 120rpx);
  435. }
  436. .formItemTitle{
  437. margin: 20rpx 0 20rpx 30rpx;
  438. }
  439. .btnbox{
  440. display: flex;
  441. position: fixed;
  442. bottom: 20rpx;
  443. }
  444. .u-form-item{
  445. background-color: #fff;
  446. }
  447. /deep/.u-form-item__body__left__content{
  448. padding-left: 30rpx;
  449. }
  450. /deep/.u-form-item__body__right{
  451. padding-right: 30rpx;
  452. }
  453. /deep/.u-form-item__body{
  454. padding: 30rpx 0;
  455. }
  456. .selectInput{
  457. display: flex;
  458. flex-direction: row;
  459. align-items: center;
  460. }
  461. .formItem {
  462. background: #fff;
  463. }
  464. .btn{
  465. width: 340rpx;
  466. height: 80rpx;
  467. background: #ffffff;
  468. border: 1rpx solid #dddddd;
  469. border-radius: 64rpx 64rpx 64rpx 64rpx;
  470. opacity: 1;
  471. font-size: 28rpx;
  472. font-weight: 500;
  473. color: #46A6FF;
  474. line-height: 80rpx;
  475. text-align: center;
  476. }
  477. .btn2{
  478. width: 650rpx;
  479. height: 80rpx;
  480. background: #46A6FF;
  481. border-radius: 64rpx 64rpx 64rpx 64rpx;
  482. opacity: 1;
  483. font-size: 28rpx;
  484. font-weight: 500;
  485. color: #FFFFFF;
  486. line-height: 80rpx;
  487. text-align: center;
  488. margin-left: 10rpx;
  489. }
  490. .margin20{
  491. margin-top: 20rpx;
  492. }
  493. .popupView{
  494. height: 430rpx;
  495. display: flex;
  496. padding-top: 100rpx;
  497. flex-direction: column;
  498. align-items: center;
  499. }
  500. .popupImg{
  501. width: 650rpx;
  502. height: 400rpx;
  503. background: #f6f6f6;
  504. border-radius: 16rpx;
  505. display: flex;
  506. align-items: center;
  507. justify-content: center;
  508. }
  509. .popupViewText{
  510. width: 600rpx;
  511. height: 120rpx;
  512. font-size: 28rpx;
  513. font-family: PingFang SC, PingFang SC-Regular;
  514. font-weight: 400;
  515. text-align: left;
  516. color: #999999;
  517. margin: 0 auto;
  518. }
  519. .btnflex{
  520. padding: 24rpx;
  521. }
  522. </style>