customerDetails.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. <template>
  2. <view :class="mask ? 'tl-show': ''">
  3. <u-cell-group :border="false">
  4. <u-cell :border="false" center title="基础信息"></u-cell>
  5. </u-cell-group>
  6. <u--form labelPosition="left" :model="form" ref="form" labelWidth="150rpx"
  7. style="margin-top: 10rpx;margin-bottom: 150rpx;">
  8. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  9. <view style="padding: 0 10rpx;">
  10. <u-form-item label="客户名称" prop="cname" borderBottom>
  11. <u-input v-model="form.cname" inputAlign="right" border="none" placeholder="请输入客户名称" />
  12. </u-form-item>
  13. <u-form-item :label="form.number?'联系人('+form.number+')':'联系人'" prop="attn" borderBottom>
  14. <u-input v-model="form.attn" inputAlign="right" border="none" placeholder="请输入联系人" />
  15. </u-form-item>
  16. <u-form-item label="电话" prop="tel" borderBottom>
  17. <u-input v-model="form.tel" inputAlign="right" border="none" placeholder="请输入电话" />
  18. </u-form-item>
  19. <u-form-item label="省市区" prop="limitAmount" borderBottom @click="mapopen">
  20. <u-input v-model="form.addr" readonly inputAlign="right" border="none" placeholder="请输入省市区"
  21. suffixIcon="map-fill" suffixIconStyle="color: #fa3534" @click="mapopen" />
  22. </u-form-item>
  23. <u-form-item label="详细地址" prop="limitAmount" borderBottom>
  24. <u-input v-model="form.details" inputAlign="right" border="none" placeholder="请选择详细地址" />
  25. <!-- <u-icon name="map" @click="getMap()"></u-icon><u-textarea v-model="form.details" border="none"
  26. placeholder="请输入详细地址" autoHeight count /> -->
  27. <!-- <view class="text-area" @click="mapopen">
  28. <text class="title">打开地图选点</text>
  29. </view> -->
  30. </u-form-item>
  31. <u-form-item label="客户分类" borderBottom @click="customerTypeShow = true">
  32. <u-input border="corpsTypeName" inputAlign="right" disabled placeholder="请选择客户分类"
  33. v-model="form.corpsTypeName" disabledColor="#ffffff" />
  34. </u-form-item>
  35. <u-form-item label="业务员" borderBottom @click="filterAll(['salesmanName','salesmanId'])">
  36. <u-input border="none" inputAlign="right" disabled placeholder="请选择业务员"
  37. v-model="form.salesmanName" disabledColor="#ffffff" />
  38. </u-form-item>
  39. <!-- <u-form-item label="账期" prop="cname" borderBottom>
  40. <u-input v-model="form.accountPeriod" inputAlign="right" border="none"
  41. placeholder="请输入帐期" />
  42. </u-form-item> -->
  43. <u-form-item label="品牌" borderBottom @click="inShowBrand">
  44. <u-input border="none" inputAlign="right" disabled placeholder="请选择品牌" v-model="form.brandName"
  45. disabledColor="#ffffff" />
  46. </u-form-item>
  47. <u-form-item label="发货仓库" borderBottom
  48. @click="filterAll(['deliveryWarehouseName','deliveryWarehouseId'])">
  49. <u-input border="none" inputAlign="right" disabled placeholder="请选择发货仓库"
  50. v-model="form.deliveryWarehouseName" disabledColor="#ffffff" />
  51. </u-form-item>
  52. <u-form-item label="商城价格" borderBottom @click="filterAll(['priceSystem','priceSystem'])">
  53. <u-input border="none" inputAlign="right" disabled placeholder="请选择商城价格"
  54. v-model="form.priceSystem" disabledColor="#ffffff" />
  55. </u-form-item>
  56. <!-- <u-form-item label="是否使用额度:" prop="ifLimitAmount" borderBottom>
  57. <u-switch v-model="form.ifLimitAmount" activeValue="1" inactiveValue="0" ></u-switch>
  58. </u-form-item> -->
  59. <u-form-item label="信用额度" prop="limitAmount" borderBottom>
  60. <u-input v-model="form.limitAmount" readonly inputAlign="right" border="none"
  61. placeholder="请输入帐期" />
  62. </u-form-item>
  63. <u-form-item v-show="form.id" label="二维码" borderBottom>
  64. <view style="display: flex;justify-content: flex-end;width: 100%;">
  65. <view style="display: flex;">
  66. <u-button style="margin-right: 10rpx;" v-show="form.id&&form.filePath" type="success"
  67. color="#fd4b09" size="mini" text="查看" @click="showImg=true"></u-button>
  68. <u-button v-show="form.id&&form.filePath" size="mini" text="重新生成" type="success"
  69. @click="geNerateQRcode()"></u-button>
  70. <u-button v-show="form.id&&!form.filePath" size="mini" text="生成" type="success"
  71. @click="geNerateQRcode()"></u-button>
  72. </view>
  73. </view>
  74. </u-form-item>
  75. <!-- <u-form-item label="信用额度" prop="creditLimit" borderBottom>
  76. <u-input v-model="form.creditLimit" inputAlign="right" border="none"
  77. placeholder="请输入帐期" />
  78. </u-form-item> -->
  79. <!-- <u-form-item label="使用信用额度" prop="useCreditLimit" borderBottom >
  80. <u-input v-model="form.useCreditLimit" inputAlign="right"
  81. disabled disabledColor="#fff" border="none" placeholder="" />
  82. </u-form-item> -->
  83. <u-form-item label="备注" prop="cname" borderBottom>
  84. <u--textarea v-model="form.remarks" border="none" placeholder="请输入备注"></u--textarea>
  85. </u-form-item>
  86. <!-- <u-form-item label="送货地址" :borderBottom="false"
  87. @click="filterAll(['corpsAddrList','corpsAddrList'])">
  88. ({{form.corpsAddrList.length}})
  89. <u-input border="none" inputAlign="right" suffixIcon="plus-circle" disabled
  90. disabledColor="#ffffff" />
  91. </u-form-item> -->
  92. </view>
  93. </view>
  94. <u-popup :show="showImg" mode="center" @close="closeImg">
  95. <view style="width: 400px;height: 400px;">
  96. <u-image style="margin-top: 50rpx;" width="100%" height="600rpx" :src="form.filePath"
  97. mode="aspectFit"></u-image>
  98. </view>
  99. </u-popup>
  100. <u-popup :show="showBrand" mode="center" @close="closeBrand" @open="openBrand" :round="10">
  101. <view style="margin: 10px;">
  102. <uni-data-checkbox multiple v-model="checkboxBrand" :localdata="brandList"
  103. :map="{text:'cname',value:'id'}" @change='brandChage'></uni-data-checkbox>
  104. <u-button type="warning" @click="pickBrand" size='mini'>确 认</u-button>
  105. </view>
  106. </u-popup>
  107. <!-- <u-image v-show="form.filePath" width="100%" height="300rpx" :src="form.filePath" mode="aspectFit"
  108. @click='showImg=true'></u-image> -->
  109. <!-- <view v-show="form.id&&!form.filePath" style="width: 96%;;margin: 20rpx auto; display: flex;">
  110. <u-button @click="geNerateQRcode()" type="primary" shape="circle" text="生成二维码"></u-button>
  111. </view> -->
  112. <!-- <u-cell-group :border="false">
  113. <u-cell :border="false" center title="客户联系人" :arrow-direction="customerContact==false?'up':'down'"
  114. :value="customerContact==false?'展开':'收起'" :isLink="true" @click="customerContact = !customerContact">
  115. <view slot="title" class="u-slot-title" style="display: flex; align-items: center;">
  116. <text style="color: #244e96;width: 150rpx;">客户联系人</text>
  117. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  118. @click.stop="contactsAddfun">
  119. 新增
  120. </view>
  121. </view>
  122. </u-cell>
  123. </u-cell-group>
  124. <view style="width: calc(96%);margin: 0 auto;border-radius: 20rpx;"
  125. v-if="customerContact">
  126. <view style="padding: 10rpx 20rpx;margin: 20rpx 0;background-color: #fff;box-sizing: border-box;"
  127. v-for="(item,index) in form.corpsAttnList" :key="index">
  128. <view style="display: flex;align-items: center;justify-content: space-between;font-size: 32rpx;margin: 10rpx 0;">
  129. <view style="color: #fd4b09;">序号{{index + 1}}</view>
  130. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  131. @click="contactsDelfun('联系人',index,item.id)" >
  132. 删除
  133. </view>
  134. </view>
  135. <u-form-item label="联系人" prop="cname" borderBottom>
  136. <u-input v-model="item.cname" inputAlign="right" border="none" placeholder="请输入联系人" />
  137. </u-form-item>
  138. <u-form-item label="电话" prop="cname" borderBottom>
  139. <u-input v-model="item.tel" inputAlign="right" border="none" placeholder="请输入电话" />
  140. </u-form-item>
  141. <u-form-item label="备注" prop="cname" borderBottom>
  142. <u--textarea v-model="item.remarks" border="none" placeholder="请输入备注" ></u--textarea>
  143. </u-form-item>
  144. </view>
  145. </view>
  146. <u-cell-group :border="false">
  147. <u-cell :border="false" center title="地址信息" :arrow-direction="addressInformation==false?'up':'down'"
  148. :value="addressInformation==false?'展开':'收起'" :isLink="true" @click="addressInformation = !addressInformation">
  149. <view slot="title" class="u-slot-title" style="display: flex; align-items: center;">
  150. <text style="color: #244e96;width: 150rpx;">地址信息</text>
  151. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  152. @click.stop="corpsAddrfun">
  153. 新增
  154. </view>
  155. </view>
  156. </u-cell>
  157. </u-cell-group>
  158. <view style="width: calc(96%);margin: 0 auto;border-radius: 20rpx;"
  159. v-if="addressInformation">
  160. <view style="padding: 10rpx 20rpx;margin: 20rpx 0;background-color: #fff;box-sizing: border-box;"
  161. v-for="(item,index) in form.corpsAddrList" :key="index">
  162. <view style="display: flex;align-items: center;justify-content: space-between;font-size: 32rpx;margin: 10rpx 0;">
  163. <view style="color: #fd4b09;">序号{{index + 1}}</view>
  164. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  165. @click="contactsDelfun('地址',index,item.id)" >
  166. 删除
  167. </view>
  168. </view>
  169. <u-form-item label="联系人" prop="cname" borderBottom>
  170. <u-input v-model="item.contacts" inputAlign="right" border="none" placeholder="请输入联系人" />
  171. </u-form-item>
  172. <u-form-item label="电话" prop="cname" borderBottom>
  173. <u-input v-model="item.tel" inputAlign="right" border="none" placeholder="请输入联系人" />
  174. </u-form-item>
  175. <u-form-item label="地址" prop="cname" borderBottom
  176. @click="belongtoareafun(index)" >
  177. <u-input v-model="item.belongtoarea" inputAlign="right" border="none" placeholder="请输入地址" />
  178. </u-form-item>
  179. <u-form-item label="详细地址" prop="cname" borderBottom>
  180. <u--textarea v-model="item.detailedAddress" border="none" placeholder="请输入详细地址" ></u--textarea>
  181. </u-form-item>
  182. <u-form-item label="备注" prop="cname" borderBottom>
  183. <u--textarea v-model="item.remarks" border="none" placeholder="请输入备注" ></u--textarea>
  184. </u-form-item>
  185. </view>
  186. </view>
  187. <u-cell-group :border="false">
  188. <u-cell :border="false" center title="图片信息" :arrow-direction="enclosure==false?'up':'down'"
  189. :value="enclosure==false?'展开':'收起'" :isLink="true" @click="enclosure = !enclosure"></u-cell>
  190. </u-cell-group>
  191. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;" v-if="enclosure">
  192. <view style="padding: 10rpx 10rpx;">
  193. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  194. :maxCount="10"></u-upload>
  195. </view>
  196. </view> -->
  197. </u--form>
  198. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;">
  199. <view style="width: 96%;;margin: 20rpx auto; display: flex;">
  200. <u-button @click="corpsDescSubmitfun" type="success" color="#fd4b09" shape="circle"
  201. text="确认提交"></u-button>
  202. <!-- <u-button type="success" color="#fd4b09" shape="circle" text="通过"></u-button>
  203. <u-button type="success" color="#fd4b09" shape="circle" text="驳回"></u-button> -->
  204. </view>
  205. </view>
  206. <!-- 客户分类多级选择 -->
  207. <u-picker :show="customerTypeShow" ref="customerTypeUPicker" keyName="title" :columns="customerTypeColumns"
  208. @confirm="customerTypeConfirm" @change="customerTypeChange" @cancel="customerTypeShow = false">
  209. </u-picker>
  210. <!-- 单列的选择框 -->
  211. <u-picker :show="pickerShow" :columns="pickerColumns" :keyName="pickerKeyName" @cancel="pickerShow = false"
  212. @confirm="pickerConfirm"></u-picker>
  213. <!-- 地址信息多级选择 -->
  214. <u-picker :show="belongtoareaShow" ref="belongtoareaUPicker" keyName="name" :columns="regionSelectData"
  215. @confirm="belongtoareaConfirm" @change="belongtoareaChange" @cancel="belongtoareaShow = false">
  216. </u-picker>
  217. <!-- <u-popup :show="DZpopupShow" @close="DZpopupShow = false,mask = false,formTwo = {}" closeable :closeOnClickOverlay="false"
  218. zIndex="10070">
  219. <view style="width: 96%;margin: auto auto;margin-top: 20rpx;padding-bottom: 20rpx;">
  220. <text>添加地址</text>
  221. <u-divider style="margin-top: 0rpx;"></u-divider>
  222. <u--form labelPosition="left" :model="formTwo" labelWidth="150rpx">
  223. <u-form-item label="详细地址" borderBottom>
  224. <u-input v-model="formTwo.detailedAddress" border="none" placeholder="请输入">
  225. <template slot="suffix">
  226. <u-button @tap="getMap" type="success" size="mini" icon="map" color="#fd4b09"></u-button>
  227. </template>
  228. </u-input>
  229. </u-form-item>
  230. </u--form>
  231. <view style="display: flex;justify-content: space-between;padding-top: 20rpx;">
  232. <view style="width: 96%;margin: 0 auto;background-color: red;">
  233. <u-button text="保存" type="primary" @click="confirmSearch" color="#fd4b09"></u-button>
  234. </view>
  235. </view>
  236. </view>
  237. </u-popup> -->
  238. <u-picker :show="showWarehouse" ref="uPicker" :defaultIndex="defaultIndex" :loading="loading" :columns="columns"
  239. :keyName="keyName" @confirm="confirmWarehouse" @change="changeHandler"
  240. @cancel="showWarehouse = false"></u-picker>
  241. </view>
  242. </template>
  243. <script>
  244. import {
  245. customerTypeAllList,
  246. clientGetUserByRole,
  247. regionSelectList,
  248. corpsDescSubmit,
  249. corpsAttnUpdate,
  250. corpsfilesRemove,
  251. corpsDescAppSubmitV1,
  252. getQRcode,
  253. getBrand
  254. } from "@/api/views/customer/index.js"
  255. import {
  256. storageDescListAll
  257. } from '@/api/OutboundTask/index.js'
  258. import {
  259. corpsDescDetail,
  260. corpsDescAppDetailsV1
  261. } from '@/api/views/sale/index.js'
  262. import {
  263. queryBrand
  264. } from '@/api/views/stock/index.js'
  265. import http from '@/http/api.js'
  266. import {
  267. corpsDescList
  268. } from '@/api/views/sale/salesOrderList.js'
  269. import {
  270. clientId,
  271. clientSecret
  272. } from '@/common/setting'
  273. export default {
  274. data() {
  275. return {
  276. showImg: false,
  277. // 数据绑定的对象
  278. form: {
  279. corpsAttnList: [{}], //客户联系人
  280. corpsAddrList: [{}], //地址信息
  281. details: null,
  282. addr: null,
  283. dimension: null,
  284. longitude: null
  285. },
  286. // 客户分类的数据
  287. customerTypeAllData: [],
  288. // 客户分类弹窗的开启
  289. customerTypeShow: false,
  290. // 多列弹窗的左侧展示的数据
  291. customerTypeColumns: [],
  292. // 多列弹窗的右侧展示的数据
  293. customerTypeColumnData: [],
  294. // 业务员请求到的数据
  295. clientGetUserByData: [],
  296. // 发货仓库请求到的数据
  297. storageDescData: [],
  298. // 商品价格接口数据
  299. queryBrandData: [],
  300. // 地理位置接口数据
  301. regionSelectData: [],
  302. // 省市区地理位置弹窗
  303. belongtoareaShow: false,
  304. // 地址信息当前选择的下标
  305. corpsAddrIndex: 0,
  306. // 单列弹窗的开启和关闭
  307. pickerShow: false,
  308. // 单列弹窗的数据
  309. pickerColumns: [],
  310. // 弹窗展示的key值
  311. pickerKeyName: '',
  312. // 客户联系人的展开和收起
  313. customerContact: true,
  314. // 地址信息的展开和收起
  315. addressInformation: true,
  316. // 图片的展开收起
  317. enclosure: false,
  318. // 地址弹窗
  319. DZpopupShow: false,
  320. mask: false,
  321. // 图片集合
  322. fileList1: [],
  323. columns: [], // 省市区数据
  324. showWarehouse: false, // 省市区弹窗
  325. keyName: 'name',
  326. loading: false,
  327. defaultIndex: [],
  328. mapData: {},
  329. errData: {},
  330. showBrand: false,
  331. brandList: [],
  332. checkboxBrand: [],
  333. }
  334. },
  335. onLoad(data) {
  336. // 客户分类接口
  337. this.customerTypeAllListfun()
  338. // 业务员接口
  339. this.clientGetUserByRolefun()
  340. // 发货仓库接口
  341. this.storageDescListAllfun()
  342. // 商城价格接口
  343. this.queryBrandfun()
  344. // 地理位置接口
  345. this.regionSelectListfun()
  346. this.getBrandfun()
  347. if (data.id) {
  348. uni.setNavigationBarTitle({
  349. title: '客户详情'
  350. })
  351. // 客户详情
  352. this.corpsDescDetailfun(data.id)
  353. }
  354. // this.getLocation()
  355. },
  356. onShow() {
  357. uni.$once('commitCheck', (data) => {
  358. this.form.details = data.name
  359. this.form.addr = data.province + "," + data.city + "," + data.district
  360. this.form.dimension = data.location ? data.location.split(',')[0] : null
  361. this.form.longitude = data.location ? data.location.split(',')[1] : null
  362. });
  363. },
  364. beforeDestroy() {
  365. console.log('移除')
  366. uni.$off();
  367. },
  368. methods: {
  369. getBrandfun() {
  370. getBrand().then(res => {
  371. this.brandList = res.data
  372. })
  373. },
  374. inShowBrand() {
  375. this.showBrand = true
  376. },
  377. pickBrand() {
  378. this.form.brandId = this.checkboxBrand.join(',')
  379. this.closeBrand()
  380. },
  381. brandChage(row) {
  382. this.form.brandName = null
  383. let brandName = []
  384. row.detail.data.forEach(e => {
  385. brandName.push(e.cname)
  386. // this.form.brandName+=e.cname
  387. })
  388. this.form.brandName = brandName.join(',')
  389. },
  390. openBrand() {
  391. if (this.form.brandId) {
  392. this.checkboxBrand = this.form.brandId.split(',')
  393. } else {
  394. this.checkboxBrand = []
  395. }
  396. },
  397. closeBrand() {
  398. this.showBrand = false
  399. },
  400. mapopen() {
  401. uni.$u.route({
  402. url: '/pages/views/customer/map/index',
  403. params: {
  404. longitude: this.form.longitude,
  405. latitude:this.form.dimension
  406. }
  407. });
  408. },
  409. getLocation() {
  410. console.log('正在获取定位')
  411. uni.getLocation({
  412. // 默认为 wgs84 返回 gps 坐标,
  413. // gcj02 返回国测局坐标,可用于 uni.openLocation 的坐标
  414. type: 'gcj02',
  415. geocode: true,
  416. isHighAccuracy: true,
  417. success: (data) => {
  418. console.log(data)
  419. this.mapData = data
  420. },
  421. fail: (err) => {
  422. console.log(err)
  423. this.errData = err
  424. uni.showToast({
  425. title: err,
  426. icon: 'none',
  427. mask: true
  428. });
  429. // this.$api.msg('获取定位失败');
  430. }
  431. })
  432. },
  433. // getMap() {
  434. // uni.request({
  435. // url: 'https://hytapi.ibisaas.com/api/Map/address', // 你的接口域名
  436. // method: 'GET', // 请求方法,根据需要可能是 'GET' 或 'POST'
  437. // data: {
  438. // // 在这里放置需要传递给API的数据
  439. // key: 'e3w243rewdsfdewtrefcre',
  440. // location: this.mapData.longitude + ',' + this.mapData.latitude
  441. // },
  442. // success: (res) => {
  443. // console.log(res.data.data.formatted_address);
  444. // this.form.details = res.data.data.formatted_address
  445. // // 处理响应数据
  446. // },
  447. // fail: (err) => {
  448. // console.error(err);
  449. // // 处理请求失败
  450. // }
  451. // });
  452. // },
  453. closeImg() {
  454. this.showImg = false
  455. },
  456. geNerateQRcode() {
  457. let obj = {}
  458. obj = {
  459. corpId: this.form.id,
  460. corpName: this.form.cname,
  461. tenantId: this.form.tenantId
  462. }
  463. uni.showLoading({
  464. title: '加载中',
  465. mask: true
  466. });
  467. getQRcode(obj).then(res => {
  468. uni.hideLoading();
  469. this.corpsDescDetailfun(this.form.id, 'open')
  470. })
  471. },
  472. // 省下拉
  473. selectAddress() {
  474. if (this.columns.length == 0) {
  475. regionSelectList().then(res => {
  476. this.columns = res.data
  477. this.showWarehouse = true
  478. })
  479. } else {
  480. this.showWarehouse = true
  481. }
  482. },
  483. confirmWarehouse(e) {
  484. this.form.addr = `${e.value[0].name},${e.value[1].name},${e.value[2].name}`
  485. this.showWarehouse = false
  486. },
  487. changeHandler(e) {
  488. console.log(e, 338);
  489. const {
  490. columnIndex,
  491. index,
  492. value,
  493. // 微信小程序无法将picker实例传出来,只能通过ref操作
  494. picker = this.$refs.uPicker
  495. } = e
  496. if (columnIndex !== 2) {
  497. this.loading = true
  498. regionSelectList({
  499. parentCode: value[columnIndex].code
  500. }).then(res => {
  501. if (columnIndex == 0) {
  502. picker.setColumnValues(columnIndex + 1, res.data[0])
  503. picker.setColumnValues(columnIndex + 2, res.data[1])
  504. } else {
  505. picker.setColumnValues(columnIndex + 1, res.data[0])
  506. }
  507. this.loading = false
  508. })
  509. }
  510. },
  511. newCategory() {
  512. uni.$u.route('/pages/views/product/customerType', {
  513. corpType: 'KH'
  514. });
  515. },
  516. // 客户联系人新增
  517. contactsAddfun() {
  518. this.form.corpsAttnList.push({})
  519. },
  520. // 客户联系人删除
  521. corpsAttnUpdatefun(index, id) {
  522. if (id) {
  523. uni.showLoading({
  524. title: '加载中',
  525. mask: true
  526. });
  527. corpsAttnUpdate({
  528. id: id
  529. }).then(res => {
  530. this.form.corpsAttnList.splice(index, 1)
  531. uni.hideLoading();
  532. })
  533. } else {
  534. this.form.corpsAttnList.splice(index, 1)
  535. }
  536. uni.showToast({
  537. title: '删除成功',
  538. icon: 'none',
  539. mask: true
  540. });
  541. },
  542. // 联系人删除地址删除
  543. contactsDelfun(type, index, id) {
  544. uni.showModal({
  545. title: '提示',
  546. content: '是否确认删除',
  547. success: (rest) => {
  548. if (rest.confirm == true) {
  549. if (type == '联系人') {
  550. this.corpsAttnUpdatefun(index, id)
  551. } else {
  552. this.corpsAddrUpdatefun(index, id)
  553. }
  554. }
  555. },
  556. })
  557. },
  558. // 地址信息新增
  559. corpsAddrfun() {
  560. this.form.corpsAddrList.push({})
  561. },
  562. // 地址信息删除
  563. corpsAddrUpdatefun(index, id) {
  564. if (id) {
  565. uni.showLoading({
  566. title: '加载中',
  567. mask: true
  568. });
  569. corpsAddrUpdate().then(res => {
  570. this.form.corpsAddrList.splice(index, 1)
  571. uni.hideLoading();
  572. })
  573. } else {
  574. this.form.corpsAddrList.splice(index, 1)
  575. }
  576. uni.showToast({
  577. title: '删除成功',
  578. icon: 'none',
  579. mask: true
  580. });
  581. },
  582. // 获取客户分类数据
  583. customerTypeAllListfun() {
  584. customerTypeAllList({
  585. corpType: 'KH'
  586. }).then(res => {
  587. this.customerTypeColumns = [res.data, res.data[0].children || []]
  588. for (let item of res.data) {
  589. if (item.children) {
  590. this.customerTypeColumnData.push(item.children)
  591. } else {
  592. this.customerTypeColumnData.push([])
  593. }
  594. }
  595. })
  596. },
  597. // 获取业务员数据
  598. clientGetUserByRolefun() {
  599. clientGetUserByRole().then(res => {
  600. this.clientGetUserByData = res
  601. })
  602. },
  603. // 获取发货仓库数据
  604. storageDescListAllfun() {
  605. storageDescListAll().then(res => {
  606. this.storageDescData = res.data
  607. })
  608. },
  609. // 获取商品价格
  610. queryBrandfun() {
  611. queryBrand({
  612. code: 'mall_price'
  613. }).then(res => {
  614. this.queryBrandData = res.data
  615. })
  616. },
  617. // 获取地理位置
  618. regionSelectListfun() {
  619. regionSelectList().then(res => {
  620. this.regionSelectData = res.data
  621. })
  622. },
  623. // 客户分类弹窗分数据
  624. customerTypeChange(e) {
  625. const {
  626. columnIndex,
  627. value,
  628. values, // values为当前变化列的数组内容
  629. index,
  630. // 微信小程序无法将picker实例传出来,只能通过ref操作
  631. picker = this.$refs.customerTypeUPicker
  632. } = e
  633. // 当第一列值发生变化时,变化第二列(后一列)对应的选项
  634. if (columnIndex === 0) {
  635. // picker为选择器this实例,变化第二列对应的选项
  636. picker.setColumnValues(1, this.customerTypeColumnData[index])
  637. }
  638. },
  639. // 客户分类确认按钮事件
  640. customerTypeConfirm(e) {
  641. if (e.value[1]) {
  642. this.form.corpsTypeId = e.value[1].id
  643. this.form.corpsTypeName = e.value[1].title
  644. } else {
  645. this.form.corpsTypeId = e.value[0].id
  646. this.form.corpsTypeName = e.value[0].title
  647. }
  648. this.customerTypeShow = false
  649. },
  650. // 省市区地理位置弹窗chenge
  651. belongtoareaChange(e) {
  652. const {
  653. columnIndex,
  654. index,
  655. value,
  656. // 微信小程序无法将picker实例传出来,只能通过ref操作
  657. picker = this.$refs.belongtoareaUPicker
  658. } = e
  659. if (columnIndex !== 2) {
  660. regionSelectList({
  661. parentCode: value[columnIndex].code
  662. }).then(res => {
  663. if (columnIndex == 0) {
  664. picker.setColumnValues(columnIndex + 1, res.data[0])
  665. picker.setColumnValues(columnIndex + 2, res.data[1])
  666. } else {
  667. picker.setColumnValues(columnIndex + 1, res.data[0])
  668. }
  669. })
  670. }
  671. },
  672. // 省市区地理位置弹窗确认事件
  673. belongtoareaConfirm(e) {
  674. this.form.corpsAddrList[this.corpsAddrIndex].belongtoarea =
  675. `${e.value[0].name},${e.value[1].name},${e.value[2].name}`
  676. this.belongtoareaShow = false
  677. },
  678. belongtoareafun(index) {
  679. this.corpsAddrIndex = index
  680. this.belongtoareaShow = true
  681. },
  682. // 详情
  683. corpsDescDetailfun(id, type) {
  684. uni.showLoading({
  685. title: '加载中',
  686. mask: true
  687. });
  688. corpsDescAppDetailsV1({
  689. id: id
  690. }).then(res => {
  691. this.form = res.data
  692. this.fileList1 = res.data.corpsFilesList
  693. for (let item of this.clientGetUserByData) {
  694. if (item.id == this.form.salesmanId) {
  695. this.form.salesmanName = item.name
  696. }
  697. }
  698. for (let item of this.storageDescData) {
  699. if (item.id == this.form.deliveryWarehouseId) {
  700. this.form.deliveryWarehouseName = item.cname
  701. }
  702. }
  703. if (type == 'open') {
  704. this.showImg = true
  705. }
  706. uni.hideLoading();
  707. })
  708. },
  709. //提交保存
  710. corpsDescSubmitfun() {
  711. if (!this.form.cname) {
  712. return uni.showToast({
  713. title: '客户名称不能为空',
  714. icon: 'none',
  715. mask: true
  716. });
  717. }
  718. if (!this.form.attn) {
  719. return uni.showToast({
  720. title: '联系人不能为空',
  721. icon: 'none',
  722. mask: true
  723. });
  724. }
  725. if (!this.form.corpsTypeName) {
  726. return uni.showToast({
  727. title: '客户分类不能为空',
  728. icon: 'none',
  729. mask: true
  730. });
  731. }
  732. if (!this.form.salesmanId) {
  733. return uni.showToast({
  734. title: '业务员不能为空',
  735. icon: 'none',
  736. mask: true
  737. });
  738. }
  739. if (!this.form.deliveryWarehouseId) {
  740. return uni.showToast({
  741. title: '发货仓库不能为空',
  742. icon: 'none',
  743. mask: true
  744. });
  745. }
  746. if (!this.form.priceSystem) {
  747. return uni.showToast({
  748. title: '商品价格不能为空',
  749. icon: 'none',
  750. mask: true
  751. });
  752. }
  753. if (!this.form.addr) {
  754. return uni.showToast({
  755. title: '省市区不能为空',
  756. icon: 'none',
  757. mask: true
  758. });
  759. }
  760. if (!this.form.details) {
  761. return uni.showToast({
  762. title: '详情地址不能为空',
  763. icon: 'none',
  764. mask: true
  765. });
  766. }
  767. // for(let index in this.form.corpsAttnList) {
  768. // if (!this.form.corpsAttnList[index].cname) {
  769. // return uni.showToast({
  770. // title: `客户联系人序号${Number(index) + 1}联系人不能为空`,
  771. // icon: 'none',
  772. // mask: true
  773. // });
  774. // }
  775. // if (!this.form.corpsAttnList[index].tel) {
  776. // return uni.showToast({
  777. // title: `客户联系人序号${Number(index) + 1}电话不能为空`,
  778. // icon: 'none',
  779. // mask: true
  780. // });
  781. // }
  782. // }
  783. // for(let index in this.form.corpsAddrList) {
  784. // if (!this.form.corpsAddrList[index].contacts) {
  785. // return uni.showToast({
  786. // title: `地址信息序号${Number(index) + 1}联系人不能为空`,
  787. // icon: 'none',
  788. // mask: true
  789. // });
  790. // }
  791. // if (!this.form.corpsAddrList[index].tel) {
  792. // return uni.showToast({
  793. // title: `地址信息序号${Number(index) + 1}电话不能为空`,
  794. // icon: 'none',
  795. // mask: true
  796. // });
  797. // }
  798. // if (!this.form.corpsAddrList[index].belongtoarea) {
  799. // return uni.showToast({
  800. // title: `地址信息序号${Number(index) + 1}地址不能为空`,
  801. // icon: 'none',
  802. // mask: true
  803. // });
  804. // }
  805. // if (!this.form.corpsAddrList[index].detailedAddress) {
  806. // return uni.showToast({
  807. // title: `地址信息序号${Number(index) + 1}详细地址不能为空`,
  808. // icon: 'none',
  809. // mask: true
  810. // });
  811. // }
  812. // }
  813. uni.showModal({
  814. title: '提示',
  815. content: '是否确认保存',
  816. success: (rest) => {
  817. if (rest.confirm == true) {
  818. uni.showLoading({
  819. title: '加载中',
  820. mask: true
  821. });
  822. if (!this.form.id) {
  823. this.form.checkStatus = '通过'
  824. }
  825. corpsDescAppSubmitV1({
  826. ...this.form,
  827. billType: 1,
  828. code: this.form.cname,
  829. corpType: "KH",
  830. corpsFilesList: this.fileList1
  831. }).then(res => {
  832. uni.hideLoading();
  833. this.corpsDescDetailfun(res.data.id)
  834. setTimeout(() => {
  835. uni.showToast({
  836. icon: "none",
  837. title: '保存成功请返回',
  838. mask: true
  839. })
  840. }, 200)
  841. })
  842. }
  843. }
  844. })
  845. },
  846. //集合筛选条件
  847. // 第一项是 绑定id ,第二项是 绑定的name
  848. filterAll(screen) {
  849. this.screen = screen
  850. switch (screen[1]) {
  851. case "salesmanId":
  852. this.pickerColumns = [this.clientGetUserByData]
  853. this.pickerShow = true,
  854. this.pickerKeyName = 'name'
  855. break;
  856. case "deliveryWarehouseId":
  857. this.pickerColumns = [this.storageDescData]
  858. this.pickerShow = true,
  859. this.pickerKeyName = 'cname'
  860. break;
  861. case "priceSystem":
  862. this.pickerColumns = [this.queryBrandData]
  863. this.pickerShow = true,
  864. this.pickerKeyName = 'dictValue'
  865. break;
  866. }
  867. },
  868. // 弹窗复制
  869. pickerConfirm(e) {
  870. switch (this.screen[1]) {
  871. case "salesmanId":
  872. this.form.salesmanId = e.value[0].id
  873. this.form.salesmanName = e.value[0].name
  874. break;
  875. case "deliveryWarehouseId":
  876. this.form.deliveryWarehouseId = e.value[0].id
  877. this.form.deliveryWarehouseName = e.value[0].cname
  878. break;
  879. case "priceSystem":
  880. this.form.priceSystem = e.value[0].dictValue
  881. break;
  882. }
  883. this.pickerShow = false
  884. },
  885. // 删除图片
  886. deletePic(event) {
  887. let this_ = this
  888. uni.showModal({
  889. title: '提示',
  890. content: '是否确认删除',
  891. success: function(rest) {
  892. if (rest.confirm == true) {
  893. if (this_[`fileList${event.name}`][event.index].id) {
  894. corpsfilesRemove({
  895. ids: this_[`fileList${event.name}`][event.index].id
  896. }).then(res => {
  897. this_[`fileList${event.name}`].splice(event.index, 1)
  898. })
  899. } else {
  900. this_[`fileList${event.name}`].splice(event.index, 1)
  901. }
  902. }
  903. }
  904. })
  905. },
  906. // 新增图片
  907. async afterRead(event) {
  908. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  909. let lists = [].concat(event.file)
  910. let fileListLen = this[`fileList${event.name}`].length
  911. lists.map((item) => {
  912. this[`fileList${event.name}`].push({
  913. ...item,
  914. })
  915. })
  916. for (let i = 0; i < lists.length; i++) {
  917. const result = await this.uploadFilePromise(lists[i].url)
  918. let item = this[`fileList${event.name}`][fileListLen]
  919. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  920. sort: this.fileList1.length,
  921. fileName: JSON.parse(result).data.originalName,
  922. url: JSON.parse(result).data.link
  923. }))
  924. fileListLen++
  925. }
  926. },
  927. uploadFilePromise(url) {
  928. return new Promise((resolve, reject) => {
  929. let a = uni.uploadFile({
  930. url: http.config.baseURL +
  931. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  932. filePath: url,
  933. name: 'file',
  934. formData: {
  935. user: 'test'
  936. },
  937. header: {
  938. // 客户端认证参数
  939. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  940. clientSecret),
  941. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  942. },
  943. success: (res) => {
  944. setTimeout(() => {
  945. resolve(res.data)
  946. }, 1000)
  947. }
  948. });
  949. })
  950. },
  951. }
  952. }
  953. </script>
  954. <style lang="scss" scoped>
  955. .tl-show {
  956. overflow: hidden;
  957. position: fixed;
  958. height: 100%;
  959. width: 100%;
  960. }
  961. ::v-deep .u-cell__body {
  962. padding: 0rpx 25rpx;
  963. margin: 10rpx 0;
  964. }
  965. ::v-deep .u-cell__title-text {
  966. color: #244e96;
  967. }
  968. ::v-deep .u-form-item__body__left__content__label {
  969. color: #fd4b09;
  970. }
  971. .selectedAddress {
  972. border-bottom: 1rpx solid #fd4b09;
  973. color: #fd4b09;
  974. }
  975. </style>