authPass.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <div class="authPass-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="authPass-back">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="authPass-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. </template>
  8. </a-page-header>
  9. <a-spin :spinning="spinning" tip="Loading...">
  10. <a-card size="small" :bordered="false" class="authPass-table-page-wrapper">
  11. <a-form-model
  12. id="authPass-form"
  13. ref="ruleForm"
  14. :model="form"
  15. :rules="rules"
  16. :label-col="formItemLayout.labelCol"
  17. :wrapper-col="formItemLayout.wrapperCol"
  18. >
  19. <a-row :gutter="15">
  20. <a-col :span="12">
  21. <a-form-model-item label="门头照片" prop="storeImage">
  22. <Upload
  23. class="upload"
  24. id="noticeEdit-imgPaths"
  25. v-model="form.storeImage"
  26. ref="storeImage"
  27. :fileSize="10"
  28. :maxNums="1"
  29. @change="changeImage1"
  30. listType="picture-card"></Upload>
  31. <div class="upload-desc">说明:单张大小小于10Mb,最多1张。</div>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :span="12">
  35. <a-form-model-item label="营业执照" prop="licenseImage">
  36. <Upload
  37. class="upload"
  38. id="noticeEdit-imgPaths"
  39. v-model="form.licenseImage"
  40. ref="licenseImage"
  41. :fileSize="10"
  42. :maxNums="1"
  43. @change="changeImage2"
  44. listType="picture-card"></Upload>
  45. <div class="upload-desc">说明:单张大小小于10Mb,最多1张。</div>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :span="12">
  49. <a-form-model-item label="门店名称" prop="storeName">
  50. <a-input id="authPass-storeName" :maxLength="30" v-model.trim="form.storeName" placeholder="请输入门店名称(最多30个字符)" allowClear />
  51. </a-form-model-item>
  52. </a-col>
  53. </a-row>
  54. <a-row :gutter="15">
  55. <a-col :span="12">
  56. <a-form-model-item label="客户地址" required style="margin: 0;">
  57. <a-row :gutter="15">
  58. <!-- 客户地址 -->
  59. <a-col span="6">
  60. <a-form-model-item prop="addrProvince">
  61. <a-select id="authPass-addrProvince" allowClear @change="getCityList" v-model="form.addrProvince" placeholder="请选择省">
  62. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  63. </a-select>
  64. </a-form-model-item>
  65. </a-col>
  66. <a-col span="6">
  67. <a-form-model-item prop="addrCity">
  68. <a-select id="authPass-addrCity" allowClear @change="getAreaList" v-model="form.addrCity" placeholder="请选择市">
  69. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  70. </a-select>
  71. </a-form-model-item>
  72. </a-col>
  73. <a-col span="6">
  74. <a-form-model-item prop="addrDistrict">
  75. <a-select id="authPass-addrDistrict" allowClear @change="areaCharged" v-model="form.addrDistrict" placeholder="请选择区/县">
  76. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  77. </a-select>
  78. </a-form-model-item>
  79. </a-col>
  80. </a-row>
  81. </a-form-model-item>
  82. </a-col>
  83. <a-col :span="12">
  84. <a-form-model-item label="详细地址" prop="addrDetail">
  85. <a-textarea id="authPass-addrDetail" :maxLength="100" v-model.trim="form.addrDetail" placeholder="请输入详细地址(最多100个字符)" allowClear />
  86. </a-form-model-item>
  87. </a-col>
  88. </a-row>
  89. <a-row :gutter="15">
  90. <a-col :span="12">
  91. <a-form-model-item label="联系人姓名" prop="contactName">
  92. <a-input
  93. id="authPass-contactName"
  94. :maxLength="30"
  95. v-model.trim="form.contactName"
  96. @change="filterEmpty"
  97. placeholder="请输入联系人姓名(最多30个字符)"
  98. allowClear />
  99. </a-form-model-item>
  100. </a-col>
  101. <a-col :span="12">
  102. <a-form-model-item label="联系人手机" prop="contactPhone">
  103. <a-input
  104. id="authPass-contactPhone"
  105. :maxLength="30"
  106. disabled
  107. v-model.trim="form.contactPhone"
  108. allowClear />
  109. </a-form-model-item>
  110. </a-col>
  111. <a-col :span="12">
  112. <a-form-model-item label="结算方式" prop="settleType">
  113. <v-select
  114. code="SHELF_SETTLE_TYPE"
  115. id="authPass-settleType"
  116. v-model="form.settleType"
  117. allowClear
  118. placeholder="请选择结算方式"
  119. ></v-select>
  120. </a-form-model-item>
  121. </a-col>
  122. <a-col :span="12">
  123. <a-form-model-item label="关联客户" prop="customerSn">
  124. <custList ref="custList" :isEnabled="true" @change="custChange" v-model="form.customerSn"></custList>
  125. </a-form-model-item>
  126. </a-col>
  127. <a-col :span="12">
  128. <a-form-model-item label="授信额度" prop="creditLimit">
  129. <a-input-number :min="100" style="width:100%" :precision="2" v-model="form.creditLimit" placeholder="请输入大于100的数字(最多允许两位小数)"></a-input-number>
  130. </a-form-model-item>
  131. </a-col>
  132. </a-row>
  133. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 30px;">
  134. <a-button type="primary" @click="saveForm" size="large" id="authPass-btn-submit" style="padding: 0 60px;">保存</a-button>
  135. </a-form-model-item>
  136. </a-form-model>
  137. </a-card>
  138. </a-spin>
  139. </div>
  140. </template>
  141. <script>
  142. import { commonMixin } from '@/utils/mixin'
  143. import { STable, VSelect, Upload } from '@/components'
  144. import { getArea } from '@/api/data'
  145. import custList from '@/views/common/custList.vue'
  146. import { xprhStoreApplyDetail, xprhStoreApplyAudit } from '@/api/approveStore'
  147. export default {
  148. name: 'ApproveStoreAuthPass',
  149. components: { STable, VSelect, custList, Upload },
  150. mixins: [commonMixin],
  151. data () {
  152. return {
  153. spinning: false,
  154. formItemLayout: {
  155. labelCol: { span: 6 },
  156. wrapperCol: { span: 16 }
  157. },
  158. form: {
  159. storeName: '', // 门店名称
  160. contactPhone: '', // 联系手机
  161. contactName: '', // 联系人
  162. addrProvince: undefined, // 省
  163. addrProvinceName: '',
  164. addrCity: undefined, // 市
  165. addrCityName: '',
  166. addrDistrict: undefined, // 区
  167. addrDistrictName: '',
  168. addrDetail: '', // 详细地址
  169. storeImage: '', // 门头照片
  170. licenseImage: '', // 营业执照
  171. settleType: '', // 结算方式
  172. customerSn: undefined, // 关联客户
  173. creditLimit: '', // 授信额度
  174. delearSn: undefined,
  175. applySn: undefined,
  176. auditStatus: 'PASS' // 通过
  177. },
  178. rules: {
  179. storeName: [{ required: true, message: '请输入门店名称', trigger: 'blur' }],
  180. contactMobile: [{ required: false, pattern: /^\d{30}$/, message: '请输入正确的手机号', trigger: 'blur' }],
  181. addrProvince: [{ required: true, message: '请选择省', trigger: 'change' }],
  182. addrCity: [{ required: true, message: '请选择市', trigger: 'change' }],
  183. addrDistrict: [{ required: true, message: '请选择区/县', trigger: 'change' }],
  184. addrDetail: [{ required: true, message: '请输入详细地址', trigger: 'change' }],
  185. contactName: [{ required: true, message: '请输入联系人姓名', trigger: 'change' }],
  186. settleType: [{ required: true, message: '请选择收结算方式', trigger: 'change' }],
  187. customerSn: [{ required: true, message: '请选择关联客户', trigger: 'change' }],
  188. creditLimit: [{ required: true, message: '请输入授信额度', trigger: 'change' }]
  189. },
  190. addrProvinceList: [], // 省下拉
  191. addrCityList: [], // 市下拉
  192. addrDistrictList: [], // 区下拉
  193. settleStyleList: [] // 收款方式 下拉数据
  194. }
  195. },
  196. methods: {
  197. filterEmpty () {
  198. let str = this.form.storeName
  199. str = str.replace(/\ +/g, '')
  200. str = str.replace(/[ ]/g, '')
  201. str = str.replace(/[\r\n]/g, '')
  202. this.form.storeName = str
  203. },
  204. // 关联客户
  205. custChange (obj, row) {
  206. this.form.customerSn = row ? obj.key : undefined
  207. },
  208. // 图片上传
  209. changeImage1 (file) {
  210. this.form.storeImage = file
  211. },
  212. // 图片上传
  213. changeImage2 (file) {
  214. this.form.licenseImage = file
  215. },
  216. // 获取客户信息
  217. getDetail () {
  218. xprhStoreApplyDetail({ sn: this.$route.params.sn }).then(res => {
  219. if (res.status == 200) {
  220. if (res.data.addrProvince) { this.getArea('city', res.data.addrProvince) }
  221. if (res.data.addrDistrict) { this.getArea('district', res.data.addrDistrict) }
  222. this.form = Object.assign(this.form, res.data)
  223. this.$refs.storeImage.setFileList(res.data.storeImage)
  224. this.$refs.licenseImage.setFileList(res.data.licenseImage)
  225. this.form.auditStatus = 'PASS' // 通过
  226. } else {
  227. this.$refs.ruleForm.resetFields()
  228. }
  229. })
  230. },
  231. // 保存
  232. saveForm () {
  233. const _this = this
  234. _this.$refs.ruleForm.validate(valid => {
  235. if (valid) {
  236. _this.$confirm({
  237. title: '操作提示',
  238. content: '审核通过后用户即可登录修配易码通,确认审核通过吗?',
  239. centered: true,
  240. closable: true,
  241. onOk () {
  242. _this.handleSubmit()
  243. }
  244. })
  245. } else {
  246. return false
  247. }
  248. })
  249. },
  250. handleSubmit (e) {
  251. const _this = this
  252. _this.spinning = true
  253. xprhStoreApplyAudit(_this.form).then(res => {
  254. if (res.status == 200) {
  255. _this.$message.success(res.message)
  256. _this.handleBack()
  257. _this.spinning = false
  258. } else {
  259. _this.spinning = false
  260. }
  261. })
  262. },
  263. // 返回列表
  264. handleBack () {
  265. this.$router.push({ name: 'approveStoreList' })
  266. },
  267. // 获取城市列表
  268. getCityList (val) {
  269. this.addrCityList = []
  270. this.addrDistrictList = []
  271. this.form.citySn = undefined
  272. this.form.countySn = undefined
  273. if (val) {
  274. this.getArea('city', val)
  275. this.form.addrProvinceName = this.addrProvinceList.find(item => item.areaSn == val).name
  276. } else {
  277. this.form.addrProvinceName = ''
  278. }
  279. },
  280. // 获取区县列表
  281. getAreaList (val) {
  282. this.addrDistrictList = []
  283. this.form.countySn = undefined
  284. if (val) {
  285. this.getArea('district', val)
  286. this.form.addrCityName = this.addrCityList.find(item => item.areaSn == val).name
  287. } else {
  288. this.form.addrCityName = ''
  289. }
  290. },
  291. // 区县变更
  292. areaCharged (val) {
  293. if (val) {
  294. this.form.addrDistrictName = this.addrDistrictList.find(item => item.areaSn == val).name
  295. } else {
  296. this.form.addrDistrictName = ''
  297. }
  298. },
  299. // 省/市/区
  300. getArea (leve, sn) {
  301. let params
  302. if (leve == 'province') {
  303. params = { type: '2' }
  304. } else {
  305. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  306. }
  307. getArea(params).then(res => {
  308. if (res.status == 200) {
  309. if (leve == 'province') {
  310. this.addrProvinceList = res.data || []
  311. } else if (leve == 'city') {
  312. this.addrCityList = res.data || []
  313. } else if (leve == 'district') {
  314. this.addrDistrictList = res.data || []
  315. }
  316. } else {
  317. if (leve == 'province') {
  318. this.addrProvinceList = []
  319. } else if (leve == 'city') {
  320. this.addrCityList = []
  321. } else if (leve == 'district') {
  322. this.addrDistrictList = []
  323. }
  324. }
  325. })
  326. },
  327. // 获取基础数据
  328. getBaseData () {
  329. this.getArea('province') // 省市区
  330. this.$refs.ruleForm.resetFields()
  331. },
  332. initPage () {
  333. this.getBaseData()
  334. // 编辑页
  335. if (this.$route.params.sn) {
  336. this.getDetail()
  337. }
  338. }
  339. },
  340. mounted () {
  341. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  342. this.initPage()
  343. }
  344. },
  345. activated () {
  346. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  347. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  348. this.initPage()
  349. }
  350. },
  351. beforeRouteEnter (to, from, next) {
  352. next(vm => {})
  353. }
  354. }
  355. </script>
  356. <style lang="less">
  357. .authPass-wrap {
  358. height: 100%;
  359. >.ant-spin-nested-loading{
  360. height: calc(100% - 52px);
  361. overflow-y: auto;
  362. .ant-spin-container{
  363. height: 100%;
  364. }
  365. .upload-desc {
  366. color:#999;
  367. clear:both;
  368. }
  369. }
  370. .authPass-back {
  371. margin-bottom: 10px;
  372. }
  373. .authPass-table-page-wrapper{
  374. height: 100%;
  375. }
  376. }
  377. </style>