customerDetails.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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="供货商分类" borderBottom
  14. @click="filterAll(['corpsTypeName','corpsTypeId'])">
  15. <u-input border="corpsTypeId" inputAlign="right" disabled placeholder="请选择供货商分类"
  16. v-model="form.corpsTypeName" disabledColor="#ffffff" />
  17. </u-form-item>
  18. <u-form-item label="电话" prop="tel" borderBottom>
  19. <u-input v-model="form.tel" inputAlign="right" border="none" placeholder="请输入电话" />
  20. </u-form-item>
  21. <u-form-item label="业务员" borderBottom
  22. @click="filterAll(['salesmanName','salesmanId'])">
  23. <u-input border="none" inputAlign="right" disabled placeholder="请选择业务员"
  24. v-model="form.salesmanName" disabledColor="#ffffff" />
  25. </u-form-item>
  26. <u-form-item label="备注" prop="cname" borderBottom>
  27. <u--textarea v-model="form.remarks" border="none" placeholder="请输入备注" ></u--textarea>
  28. </u-form-item>
  29. </view>
  30. </view>
  31. <u-cell-group :border="false">
  32. <u-cell :border="false" center title="联系人信息" :arrow-direction="customerContact==false?'up':'down'"
  33. :value="customerContact==false?'展开':'收起'" :isLink="true" @click="customerContact = !customerContact">
  34. <view slot="title" class="u-slot-title" style="display: flex; align-items: center;">
  35. <text style="color: #244e96;width: 150rpx;">联系人信息</text>
  36. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  37. @click.stop="contactsAddfun">
  38. 新增
  39. </view>
  40. </view>
  41. </u-cell>
  42. </u-cell-group>
  43. <view style="width: calc(96%);margin: 0 auto;border-radius: 20rpx;"
  44. v-if="customerContact">
  45. <view style="padding: 10rpx 20rpx;margin: 20rpx 0;background-color: #fff;box-sizing: border-box;"
  46. v-for="(item,index) in form.corpsAttnList" :key="index">
  47. <view style="display: flex;align-items: center;justify-content: space-between;font-size: 32rpx;margin: 10rpx 0;">
  48. <view style="color: #fd4b09;">序号{{index + 1}}</view>
  49. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  50. @click="contactsDelfun('联系人',index,item.id)" >
  51. 删除
  52. </view>
  53. </view>
  54. <u-form-item label="联系人" prop="cname" borderBottom>
  55. <u-input v-model="item.cname" inputAlign="right" border="none" placeholder="请输入联系人" />
  56. </u-form-item>
  57. <u-form-item label="电话" prop="cname" borderBottom>
  58. <u-input v-model="item.tel" inputAlign="right" border="none" placeholder="请输入电话" />
  59. </u-form-item>
  60. <u-form-item label="备注" prop="cname" borderBottom>
  61. <u--textarea v-model="item.remarks" border="none" placeholder="请输入备注" ></u--textarea>
  62. </u-form-item>
  63. </view>
  64. </view>
  65. <u-cell-group :border="false">
  66. <u-cell :border="false" center title="地址信息" :arrow-direction="addressInformation==false?'up':'down'"
  67. :value="addressInformation==false?'展开':'收起'" :isLink="true" @click="addressInformation = !addressInformation">
  68. <view slot="title" class="u-slot-title" style="display: flex; align-items: center;">
  69. <text style="color: #244e96;width: 150rpx;">地址信息</text>
  70. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  71. @click.stop="corpsAddrfun">
  72. 新增
  73. </view>
  74. </view>
  75. </u-cell>
  76. </u-cell-group>
  77. <view style="width: calc(96%);margin: 0 auto;border-radius: 20rpx;"
  78. v-if="addressInformation">
  79. <view style="padding: 10rpx 20rpx;margin: 20rpx 0;background-color: #fff;box-sizing: border-box;"
  80. v-for="(item,index) in form.corpsAddrList" :key="index">
  81. <view style="display: flex;align-items: center;justify-content: space-between;font-size: 32rpx;margin: 10rpx 0;">
  82. <view style="color: #fd4b09;">序号{{index + 1}}</view>
  83. <view style="margin-left: 10rpx; background: #fd4b09;color: #fff;border-radius: 10rpx;padding: 5rpx 10px;"
  84. @click="contactsDelfun('地址',index,item.id)" >
  85. 删除
  86. </view>
  87. </view>
  88. <u-form-item label="地址" prop="cname" borderBottom
  89. @click="belongtoareafun(index)" >
  90. <u-input v-model="item.belongtoarea" inputAlign="right" border="none" placeholder="请输入地址" />
  91. </u-form-item>
  92. <u-form-item label="详细地址" prop="cname" borderBottom>
  93. <u--textarea v-model="item.detailedAddress" border="none" placeholder="请输入详细地址" ></u--textarea>
  94. </u-form-item>
  95. <u-form-item label="备注" prop="cname" borderBottom>
  96. <u--textarea v-model="item.remarks" border="none" placeholder="请输入备注" ></u--textarea>
  97. </u-form-item>
  98. </view>
  99. </view>
  100. <u-cell-group :border="false">
  101. <u-cell :border="false" center title="图片信息" :arrow-direction="enclosure==false?'up':'down'"
  102. :value="enclosure==false?'展开':'收起'" :isLink="true" @click="enclosure = !enclosure"></u-cell>
  103. </u-cell-group>
  104. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;" v-if="enclosure">
  105. <view style="padding: 10rpx 10rpx;">
  106. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  107. :maxCount="10"></u-upload>
  108. </view>
  109. </view>
  110. </u--form>
  111. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;">
  112. <view style="width: 96%;;margin: 20rpx auto;">
  113. <u-button @click="corpsDescSubmitfun" type="success" color="#fd4b09" shape="circle" text="确认提交"></u-button>
  114. </view>
  115. </view>
  116. <!-- 单列的选择框 -->
  117. <u-picker :show="pickerShow" :columns="pickerColumns" :keyName="pickerKeyName"
  118. @cancel="pickerShow = false" @confirm="pickerConfirm"></u-picker>
  119. <!-- 地址信息多级选择 -->
  120. <u-picker :show="belongtoareaShow" ref="belongtoareaUPicker" keyName="name"
  121. :columns="regionSelectData"
  122. @confirm="belongtoareaConfirm" @change="belongtoareaChange" @cancel="belongtoareaShow = false">
  123. </u-picker>
  124. <!-- <u-popup :show="DZpopupShow" @close="DZpopupShow = false,mask = false,formTwo = {}" closeable :closeOnClickOverlay="false"
  125. zIndex="10070">
  126. <view style="width: 96%;margin: auto auto;margin-top: 20rpx;padding-bottom: 20rpx;">
  127. <text>添加地址</text>
  128. <u-divider style="margin-top: 0rpx;"></u-divider>
  129. <u--form labelPosition="left" :model="formTwo" labelWidth="150rpx">
  130. <u-form-item label="详细地址" borderBottom>
  131. <u-input v-model="formTwo.detailedAddress" border="none" placeholder="请输入">
  132. <template slot="suffix">
  133. <u-button @tap="getMap" type="success" size="mini" icon="map" color="#fd4b09"></u-button>
  134. </template>
  135. </u-input>
  136. </u-form-item>
  137. </u--form>
  138. <view style="display: flex;justify-content: space-between;padding-top: 20rpx;">
  139. <view style="width: 96%;margin: 0 auto;background-color: red;">
  140. <u-button text="保存" type="primary" @click="confirmSearch" color="#fd4b09"></u-button>
  141. </view>
  142. </view>
  143. </view>
  144. </u-popup> -->
  145. <u-toast ref="uToast"></u-toast>
  146. </view>
  147. </template>
  148. <script>
  149. import {
  150. clientGetUserByRole,
  151. regionSelectList,
  152. corpsDescSubmit,
  153. corpsAttnUpdate,
  154. corpstypeTree
  155. } from "@/api/views/customer/index.js"
  156. import { storageDescListAll } from '@/api/OutboundTask/index.js'
  157. import {corpsDescDetail } from '@/api/views/sale/index.js'
  158. import { queryBrand } from '@/api/views/stock/index.js'
  159. import http from '@/http/api.js'
  160. import {corpsDescList} from '@/api/views/sale/salesOrderList.js'
  161. import {
  162. clientId,
  163. clientSecret
  164. } from '@/common/setting'
  165. export default {
  166. data() {
  167. return {
  168. // 数据绑定的对象
  169. form: {
  170. corpsAttnList:[{}], //联系人信息
  171. corpsAddrList:[{}] //地址信息
  172. },
  173. corpsTypeData:[],
  174. // 业务员请求到的数据
  175. clientGetUserByData:[],
  176. // 发货仓库请求到的数据
  177. storageDescData:[],
  178. // 商品价格接口数据
  179. queryBrandData:[],
  180. // 地理位置接口数据
  181. regionSelectData:[],
  182. // 省市区地理位置弹窗
  183. belongtoareaShow:false,
  184. // 地址信息当前选择的下标
  185. corpsAddrIndex:0,
  186. // 单列弹窗的开启和关闭
  187. pickerShow:false,
  188. // 单列弹窗的数据
  189. pickerColumns:[],
  190. // 弹窗展示的key值
  191. pickerKeyName:'',
  192. // 联系人信息的展开和收起
  193. customerContact:true,
  194. // 地址信息的展开和收起
  195. addressInformation:true,
  196. // 图片的展开收起
  197. enclosure:false,
  198. // 地址弹窗
  199. DZpopupShow:false,
  200. mask:false,
  201. // 图片集合
  202. fileList1:[]
  203. }
  204. },
  205. onLoad(data) {
  206. // 客户分类接口
  207. this.corpstypeTreefun()
  208. // 业务员接口
  209. this.clientGetUserByRolefun()
  210. // 发货仓库接口
  211. this.storageDescListAllfun()
  212. // 商城价格接口
  213. this.queryBrandfun()
  214. // 地理位置接口
  215. this.regionSelectListfun()
  216. if (data.id) {
  217. uni.setNavigationBarTitle({
  218. title: '客户详情'
  219. })
  220. // 供应商详情
  221. this.corpsDescDetailfun(data.id)
  222. }
  223. },
  224. methods: {
  225. newCategory(){
  226. uni.$u.route('/pages/views/product/customerType',{
  227. corpType:'KH'
  228. });
  229. },
  230. // 联系人信息新增
  231. contactsAddfun(){
  232. this.form.corpsAttnList.push({})
  233. },
  234. // 联系人信息删除
  235. corpsAttnUpdatefun(index,id){
  236. if (id) {
  237. uni.showLoading({
  238. title: '加载中',
  239. mask: true
  240. });
  241. corpsAttnUpdate({id:id}).then(res=>{
  242. this.form.corpsAttnList.splice(index, 1)
  243. uni.hideLoading();
  244. })
  245. }else {
  246. this.form.corpsAttnList.splice(index, 1)
  247. }
  248. uni.showToast({
  249. title: '删除成功',
  250. icon: 'none',
  251. mask: true
  252. });
  253. },
  254. // 联系人删除地址删除
  255. contactsDelfun(type,index,id){
  256. uni.showModal({
  257. title: '提示',
  258. content: '是否确认删除',
  259. success: (rest)=> {
  260. if (rest.confirm == true) {
  261. if (type == '联系人') {
  262. this.corpsAttnUpdatefun(index,id)
  263. }else {
  264. this.corpsAddrUpdatefun(index,id)
  265. }
  266. }
  267. },
  268. })
  269. },
  270. // 地址信息新增
  271. corpsAddrfun(){
  272. this.form.corpsAddrList.push({})
  273. },
  274. // 地址信息删除
  275. corpsAddrUpdatefun(index,id){
  276. if (id) {
  277. uni.showLoading({
  278. title: '加载中',
  279. mask: true
  280. });
  281. corpsAddrUpdate().then(res=>{
  282. this.form.corpsAddrList.splice(index, 1)
  283. uni.hideLoading();
  284. })
  285. }else {
  286. this.form.corpsAddrList.splice(index, 1)
  287. }
  288. uni.showToast({
  289. title: '删除成功',
  290. icon: 'none',
  291. mask: true
  292. });
  293. },
  294. // 获取供应商分类数据
  295. corpstypeTreefun(){
  296. corpstypeTree({corpType:'GYS'}).then(res=>{
  297. console.log(res.data,323);
  298. this.corpsTypeData = res.data
  299. })
  300. },
  301. // 获取业务员数据
  302. clientGetUserByRolefun(){
  303. clientGetUserByRole().then(res=>{
  304. this.clientGetUserByData = res
  305. })
  306. },
  307. // 获取发货仓库数据
  308. storageDescListAllfun(){
  309. storageDescListAll().then(res=>{
  310. this.storageDescData = res.data
  311. })
  312. },
  313. // 获取商品价格
  314. queryBrandfun(){
  315. queryBrand({code: 'mall_price'}).then(res=>{
  316. this.queryBrandData = res.data
  317. })
  318. },
  319. // 获取地理位置
  320. regionSelectListfun(){
  321. regionSelectList().then(res=>{
  322. this.regionSelectData = res.data
  323. })
  324. },
  325. // 省市区地理位置弹窗chenge
  326. belongtoareaChange(e) {
  327. const {
  328. columnIndex,
  329. index,
  330. value,
  331. // 微信小程序无法将picker实例传出来,只能通过ref操作
  332. picker = this.$refs.belongtoareaUPicker
  333. } = e
  334. if (columnIndex !== 2) {
  335. regionSelectList({
  336. parentCode: value[columnIndex].code
  337. }).then(res => {
  338. if (columnIndex == 0) {
  339. picker.setColumnValues(columnIndex + 1, res.data[0])
  340. picker.setColumnValues(columnIndex + 2, res.data[1])
  341. } else {
  342. picker.setColumnValues(columnIndex + 1, res.data[0])
  343. }
  344. })
  345. }
  346. },
  347. // 省市区地理位置弹窗确认事件
  348. belongtoareaConfirm(e){
  349. console.log(e);
  350. this.form.corpsAddrList[this.corpsAddrIndex].belongtoarea = `${e.value[0].name},${e.value[1].name},${e.value[2].name}`
  351. this.belongtoareaShow = false
  352. },
  353. belongtoareafun(index){
  354. this.corpsAddrIndex = index
  355. this.belongtoareaShow = true
  356. },
  357. // 详情
  358. corpsDescDetailfun(id) {
  359. uni.showLoading({
  360. title: '加载中',
  361. mask: true
  362. });
  363. corpsDescDetail({
  364. id: id
  365. }).then(res => {
  366. this.form = res.data
  367. this.fileList1 = res.data.corpsFilesList
  368. for(let item of this.clientGetUserByData) {
  369. if (item.id == this.form.salesmanId) {
  370. this.form.salesmanName = item.name
  371. }
  372. }
  373. uni.hideLoading();
  374. })
  375. },
  376. //提交保存
  377. corpsDescSubmitfun() {
  378. if (!this.form.cname) {
  379. return uni.showToast({
  380. title: '客户名称不能为空',
  381. icon: 'none',
  382. mask: true
  383. });
  384. }
  385. if (!this.form.corpsTypeName) {
  386. return uni.showToast({
  387. title: '客户分类不能为空',
  388. icon: 'none',
  389. mask: true
  390. });
  391. }
  392. if (!this.form.salesmanId) {
  393. return uni.showToast({
  394. title: '业务员不能为空',
  395. icon: 'none',
  396. mask: true
  397. });
  398. }
  399. for(let index in this.form.corpsAttnList) {
  400. if (!this.form.corpsAttnList[index].cname) {
  401. return uni.showToast({
  402. title: `联系人信息序号${Number(index) + 1}联系人不能为空`,
  403. icon: 'none',
  404. mask: true
  405. });
  406. }
  407. if (!this.form.corpsAttnList[index].tel) {
  408. return uni.showToast({
  409. title: `联系人信息序号${Number(index) + 1}电话不能为空`,
  410. icon: 'none',
  411. mask: true
  412. });
  413. }
  414. }
  415. for(let index in this.form.corpsAddrList) {
  416. if (!this.form.corpsAddrList[index].belongtoarea) {
  417. return uni.showToast({
  418. title: `地址信息序号${Number(index) + 1}地址不能为空`,
  419. icon: 'none',
  420. mask: true
  421. });
  422. }
  423. if (!this.form.corpsAddrList[index].detailedAddress) {
  424. return uni.showToast({
  425. title: `地址信息序号${Number(index) + 1}详细地址不能为空`,
  426. icon: 'none',
  427. mask: true
  428. });
  429. }
  430. }
  431. uni.showModal({
  432. title: '提示',
  433. content: '是否确认保存',
  434. success: (rest)=> {
  435. if (rest.confirm == true) {
  436. uni.showLoading({
  437. title: '加载中',
  438. mask: true
  439. });
  440. corpsDescSubmit({
  441. ...this.form,
  442. // billType: 1,
  443. // code: this.form.cname,
  444. corpType: "GYS",
  445. corpsFilesList:this.fileList1
  446. }).then(res => {
  447. uni.hideLoading();
  448. this.$refs.uToast.show({
  449. type: 'success',
  450. message: "保存成功",
  451. })
  452. this.corpsDescDetailfun(res.data.id)
  453. })
  454. }
  455. }
  456. })
  457. },
  458. //集合筛选条件
  459. // 第一项是 绑定id ,第二项是 绑定的name
  460. filterAll(screen) {
  461. this.screen = screen
  462. switch (screen[1]) {
  463. case "salesmanId":
  464. this.pickerColumns = [this.clientGetUserByData]
  465. this.pickerShow = true,
  466. this.pickerKeyName = 'name'
  467. break;
  468. case "corpsTypeId":
  469. this.pickerColumns = [this.corpsTypeData]
  470. this.pickerShow = true,
  471. this.pickerKeyName = 'title'
  472. break;
  473. }
  474. },
  475. // 弹窗复制
  476. pickerConfirm(e) {
  477. switch (this.screen[1]) {
  478. case "salesmanId":
  479. this.form.salesmanId = e.value[0].id
  480. this.form.salesmanName = e.value[0].name
  481. break;
  482. case "corpsTypeId":
  483. this.form.corpsTypeId = e.value[0].id
  484. this.form.corpsTypeName = e.value[0].title
  485. break;
  486. }
  487. this.pickerShow = false
  488. },
  489. // 删除图片
  490. deletePic(event) {
  491. let this_ = this
  492. uni.showModal({
  493. title: '提示',
  494. content: '是否确认删除',
  495. success: function(rest) {
  496. if (rest.confirm == true) {
  497. if (this_[`fileList${event.name}`][event.index].id) {
  498. removeFile({
  499. ids: this_[`fileList${event.name}`][event.index].id
  500. }).then(res => {
  501. this_[`fileList${event.name}`].splice(event.index, 1)
  502. })
  503. } else {
  504. this_[`fileList${event.name}`].splice(event.index, 1)
  505. }
  506. }
  507. }
  508. })
  509. },
  510. // 新增图片
  511. async afterRead(event) {
  512. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  513. let lists = [].concat(event.file)
  514. let fileListLen = this[`fileList${event.name}`].length
  515. lists.map((item) => {
  516. this[`fileList${event.name}`].push({
  517. ...item,
  518. })
  519. })
  520. for (let i = 0; i < lists.length; i++) {
  521. const result = await this.uploadFilePromise(lists[i].url)
  522. let item = this[`fileList${event.name}`][fileListLen]
  523. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  524. sort: this.fileList1.length,
  525. fileName: JSON.parse(result).data.originalName,
  526. url: JSON.parse(result).data.link
  527. }))
  528. fileListLen++
  529. }
  530. },
  531. uploadFilePromise(url) {
  532. return new Promise((resolve, reject) => {
  533. let a = uni.uploadFile({
  534. url: http.config.baseURL +
  535. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  536. filePath: url,
  537. name: 'file',
  538. formData: {
  539. user: 'test'
  540. },
  541. header: {
  542. // 客户端认证参数
  543. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' + clientSecret),
  544. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  545. },
  546. success: (res) => {
  547. setTimeout(() => {
  548. resolve(res.data)
  549. }, 1000)
  550. }
  551. });
  552. })
  553. },
  554. }
  555. }
  556. </script>
  557. <style lang="scss" scoped>
  558. .tl-show {
  559. overflow: hidden;
  560. position: fixed;
  561. height: 100%;
  562. width: 100%;
  563. }
  564. ::v-deep .u-cell__body {
  565. padding: 0rpx 25rpx;
  566. margin: 10rpx 0;
  567. }
  568. ::v-deep .u-cell__title-text {
  569. color: #244e96;
  570. }
  571. ::v-deep .u-form-item__body__left__content__label {
  572. color: #fd4b09;
  573. }
  574. .selectedAddress {
  575. border-bottom: 1rpx solid #fd4b09;
  576. color: #fd4b09;
  577. }
  578. </style>