add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="this.form.id?'修改客户':'新建客户'" @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  7. <u-cell-group v-show='current==0'>
  8. <u-cell :title="'客户分类'" arrow-direction="down">
  9. <view slot="title" style="display: flex; align-items: center;">
  10. <text class="required-mark">*</text>
  11. 客户分类
  12. </view>
  13. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.categoryName"
  14. @click.native="showPicker"></u--input>
  15. </u-cell>
  16. <u-cell :title="'客户名称'" arrow-direction="down">
  17. <view slot="title" style="display: flex; align-items: center;">
  18. <text class="required-mark">*</text>
  19. 客户名称
  20. </view>
  21. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.name"></u--input>
  22. </u-cell>
  23. <u-cell title="客户代号" arrow-direction="down">
  24. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.serialNo"></u--input>
  25. </u-cell>
  26. <u-cell title="客户简称" arrow-direction="down">
  27. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.simpleName"></u--input>
  28. </u-cell>
  29. <u-cell title="法定代表人" arrow-direction="down">
  30. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.legalPerson"></u--input>
  31. </u-cell>
  32. <u-cell title="注册资金" arrow-direction="down">
  33. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.registeredCapital"></u--input>
  34. </u-cell>
  35. <u-cell :title="'授信额度'" arrow-direction="down">
  36. <view slot="title" style="display: flex; align-items: center;">
  37. <text class="required-mark">*</text>
  38. 授信额度
  39. </view>
  40. <u--input type="number" slot="value" placeholder="请输入" border="surround"
  41. v-model="form.authorizationLimit"></u--input>
  42. </u-cell>
  43. <u-cell title="单位电话" arrow-direction="down">
  44. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.phone"></u--input>
  45. </u-cell>
  46. <u-cell :title="'注册地址'" arrow-direction="down">
  47. <view slot="title" style="display: flex; align-items: center;">
  48. <text class="required-mark">*</text>
  49. 注册地址
  50. </view>
  51. <uni-data-picker v-model="address" :map="{text:'label',value:'value'}" slot="value" placeholder="请选择地址"
  52. popup-title="请选择城市" :localdata="chinaData" @change="onchange">
  53. </uni-data-picker>
  54. </u-cell>
  55. <u-cell title="详细地址" arrow-direction="down">
  56. <u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.address"></u--textarea>
  57. </u-cell>
  58. <u-cell title="联系地址" arrow-direction="down">
  59. <uni-data-picker v-model="address1" :map="{text:'label',value:'value'}" slot="value" placeholder="请选择地址"
  60. popup-title="请选择城市" :localdata="chinaData" @change="onchange1">
  61. </uni-data-picker>
  62. </u-cell>
  63. <u-cell title="详细地址" arrow-direction="down">
  64. <u--textarea slot="value" placeholder="请输入" border="surround" v-model="otherForm.address"></u--textarea>
  65. </u-cell>
  66. <u-cell title="统一社会信用代码" arrow-direction="down">
  67. <u--input slot="value" placeholder="请输入" border="surround"
  68. v-model="form.unifiedSocialCreditCode"></u--input>
  69. </u-cell>
  70. <u-cell title="所属行业" arrow-direction="down">
  71. <uni-data-picker v-model="form.industry" :map="{text:'label',value:'value'}" slot="value"
  72. placeholder="请选择" :localdata="categoryData" @change="industryOnchange">
  73. </uni-data-picker>
  74. </u-cell>
  75. <u-cell title="营业类型" arrow-direction="down">
  76. <uni-data-picker v-model="form.companyCategoryId" slot="value" placeholder="请选择"
  77. :localdata="company_category">
  78. </uni-data-picker>
  79. </u-cell>
  80. <u-cell title="企业类型" arrow-direction="down">
  81. <uni-data-picker v-model="form.enterpriseTypeId" slot="value" placeholder="请选择"
  82. :localdata="enterprise_type">
  83. </uni-data-picker>
  84. </u-cell>
  85. <u-cell title="登记日期" arrow-direction="down">
  86. <uni-datetime-picker type="date" slot="value" v-model="form.registerDate">
  87. </uni-datetime-picker>
  88. </u-cell>
  89. <u-cell title="主营产品" arrow-direction="down">
  90. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.mainProduct"></u--input>
  91. </u-cell>
  92. <u-cell title="级别" arrow-direction="down">
  93. <uni-data-picker v-model="form.level" slot="value" placeholder="请选择" :localdata="contact_level">
  94. </uni-data-picker>
  95. </u-cell>
  96. <!-- <u-cell title="结算方式" arrow-direction="down">
  97. <uni-data-picker v-model="otherForm.settlementMode" slot="value" placeholder="请选择"
  98. :localdata="settlement_mode">
  99. </uni-data-picker>
  100. </u-cell>
  101. <u-cell title="税率" arrow-direction="down">
  102. <u--input type="number" slot="value" placeholder="请输入" border="surround"
  103. v-model="otherForm.taxRate"></u--input>
  104. </u-cell>
  105. <u-cell title="折扣率" arrow-direction="down">
  106. <u--input type="number" slot="value" placeholder="请输入" border="surround"
  107. v-model="otherForm.discount"></u--input>
  108. </u-cell>
  109. <u-cell title="收件人" arrow-direction="down">
  110. <u--input slot="value" placeholder="请输入" border="surround" v-model="otherForm.sender"></u--input>
  111. </u-cell>
  112. <u-cell title="收件人电话" arrow-direction="down">
  113. <u--input slot="value" placeholder="请输入" border="surround" v-model="otherForm.senderPhone"></u--input>
  114. </u-cell> -->
  115. <u-cell title="经营范围" arrow-direction="down">
  116. <u--textarea slot="value" placeholder="请输入" border="surround"
  117. v-model="form.businessScope"></u--textarea>
  118. </u-cell>
  119. <u-cell title="营业执照附件" arrow-direction="down">
  120. <fileMain slot="value" v-model="form.businessLicenseFile"></fileMain>
  121. </u-cell>
  122. <u-cell title="备注" arrow-direction="down">
  123. <u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.remark"></u--textarea>
  124. </u-cell>
  125. </u-cell-group>
  126. <bankList ref="bankListRef" v-show='current==1'></bankList>
  127. <linkList :contact_link_status="contact_link_status" ref="linkListRef" v-show='current==2'></linkList>
  128. <ba-tree-picker ref="treePicker" @select-change="selectChange" :multiple='true' :localdata="treeList" />
  129. <view class="footerButton">
  130. <u-button type="default" text="返回" @click="back"></u-button>
  131. <u-button type="primary" @click="save" text="保存"></u-button>
  132. </view>
  133. <u-toast ref="uToast"></u-toast>
  134. </view>
  135. </template>
  136. <script>
  137. import baTreePicker from "@/components/ba-tree-picker1/ba-tree-picker.vue"
  138. import fileMain from "@/pages/doc/index.vue"
  139. import bankList from "./components/bankList.vue"
  140. import linkList from "./components/linkList.vue"
  141. import {
  142. getTreeByPid
  143. } from "@/api/classifyManage/index.js"
  144. import {
  145. categoryData
  146. } from 'element-china-category-data';
  147. import {
  148. getByCode
  149. } from '@/api/pda/common.js'
  150. import {
  151. contactSave,
  152. contactDetail,
  153. getInfoByIds
  154. } from '@/api/saleManage/contact/index.js'
  155. const chinaData = require("@/static/json/regions-data.json")
  156. export default {
  157. components: {
  158. baTreePicker,
  159. bankList,
  160. linkList,
  161. fileMain
  162. },
  163. data() {
  164. return {
  165. list: ['基本信息', '银行信息', '联系人信息'],
  166. current: 0,
  167. chinaData,
  168. categoryData,
  169. categoryIdList: [],
  170. address: '',
  171. address1: '',
  172. categoryShow: false,
  173. form: {
  174. address: '',
  175. addressId: '',
  176. addressName: '',
  177. authorizationLimit: 0,
  178. businessLicenseFiles: [],
  179. businessLicenseFile: [],
  180. businessScope: '',
  181. categoryId: '',
  182. categoryName: '',
  183. companyCategoryId: '',
  184. companyCategoryName: '',
  185. enterpriseTypeId: '',
  186. enterpriseTypeName: '',
  187. legalPerson: '',
  188. registeredCapital: '',
  189. parentId: '',
  190. industry: [],
  191. industryCode: '',
  192. industryFullName: '',
  193. mainProduct: '',
  194. name: '',
  195. officialIndustry: '',
  196. phone: '',
  197. registerDate: '',
  198. remark: '',
  199. serialNo: '',
  200. simpleName: '',
  201. type: 1,
  202. unifiedSocialCreditCode: ''
  203. },
  204. otherForm: {
  205. settlementMode: '',
  206. settlementModeName: '',
  207. taxRate: 0,
  208. address: '',
  209. addressId: '',
  210. deptId: '',
  211. deptName: '',
  212. discount: 0,
  213. salesmanId: '',
  214. salesmanName: '',
  215. sender: '',
  216. senderPhone: ''
  217. },
  218. treeList: [],
  219. bankList: [],
  220. linkList: [],
  221. company_category: [],
  222. enterprise_type: [],
  223. contact_level: [],
  224. contact_link_status: [],
  225. settlement_mode: []
  226. }
  227. },
  228. created() {
  229. getTreeByPid(17).then(res => {
  230. this.treeList = res.data
  231. });
  232. // await getTreeByPid(17);
  233. this.getByCode()
  234. },
  235. onLoad(data) {
  236. if (data && data.id) {
  237. contactDetail(data.id).then(res => {
  238. this.form = res.base
  239. this.otherForm = res.other
  240. this.bankList = res.bankList
  241. this.linkList = res.linkList
  242. this.address = this.form.addressId && this.form.addressId.split(',')
  243. this.address1 = this.otherForm.addressId && this.otherForm.addressId.split(',')
  244. this.form.industry = this.form.industryCode && this.form.industryCode.split(',')
  245. this.form.level = this.form.level + ''
  246. this.otherForm.settlementMode = this.otherForm.settlementMode + ''
  247. this.categoryIdList = this.form.categoryId && this.form.categoryId.split(',')
  248. getInfoByIds(this.form.categoryId).then((res) => {
  249. let categoryName = res.map((item) => item.name)?.join(',');
  250. this.$set(this.form, 'categoryName', categoryName);
  251. });
  252. this.$nextTick(() => {
  253. this.$refs.bankListRef.init(this.bankList)
  254. this.$refs.linkListRef.init(this.linkList)
  255. })
  256. })
  257. }
  258. },
  259. onUnload() {
  260. uni.$off('updateBankList')
  261. uni.$off('updatelinkList')
  262. },
  263. methods: {
  264. // 显示选择器
  265. showPicker() {
  266. this.$refs.treePicker._show(this.categoryIdList);
  267. },
  268. getByCode() {
  269. const codeS = ['company_category', 'enterprise_type', 'contact_level', 'contact_link_status',
  270. 'settlement_mode'
  271. ]
  272. codeS.forEach(async (code) => {
  273. const codeValue = await getByCode(code);
  274. this[code] = codeValue.map(item => {
  275. const key = Object.keys(item)[0]
  276. return {
  277. value: key,
  278. text: item[key]
  279. }
  280. })
  281. })
  282. },
  283. //监听选择(ids为数组)
  284. selectChange(data = []) {
  285. this.categoryIdList = data.map(item => item.id)
  286. this.form.categoryId = data.map(item => item.id).toString()
  287. this.form.categoryName = data.map(item => item.name).toString()
  288. // console.log(data)
  289. },
  290. scrolltolower() {
  291. this.$refs.myListRef.getList()
  292. },
  293. onchange(e) {
  294. const value = e.detail.value
  295. this.form.addressId = value.map(item => item.value).toString()
  296. this.form.addressName = value.map(item => item.text).toString()
  297. },
  298. onchange1(e) {
  299. const value = e.detail.value
  300. this.otherForm.addressId = value.map(item => item.value).toString()
  301. this.otherForm.addressName = value.map(item => item.text).toString()
  302. },
  303. industryOnchange(e) {
  304. const value = e.detail.value
  305. this.form.industryCode = value.map(item => item.value).toString()
  306. this.form.industryFullName = value.map(item => item.text).toString()
  307. },
  308. sectionChange(index) {
  309. this.current = index;
  310. },
  311. async save() {
  312. try {
  313. if (!this.form.categoryId) {
  314. this.$refs.uToast.show({
  315. type: "error",
  316. message: "请选择客户分类",
  317. })
  318. return
  319. }
  320. if (!this.form.name) {
  321. this.$refs.uToast.show({
  322. type: "error",
  323. message: "请输入客户名称",
  324. })
  325. return
  326. }
  327. if (!this.form.authorizationLimit && this.form.authorizationLimit !== 0) {
  328. this.$refs.uToast.show({
  329. type: "error",
  330. message: "请输入授信额度",
  331. })
  332. return
  333. }
  334. if (!this.form.addressId) {
  335. this.$refs.uToast.show({
  336. type: "error",
  337. message: "请选择地址",
  338. })
  339. return
  340. }
  341. this.form.companyCategoryName = this.company_category.find(item => item.value == this.form
  342. .companyCategoryId)?.text
  343. this.form.enterpriseTypeName = this.enterprise_type.find(item => item.value == this.form
  344. .enterpriseTypeId)?.text
  345. this.form.settlementModeName = this.settlement_mode.find(item => item.value == this.form
  346. .settlementMode)?.text
  347. // return;
  348. uni.showLoading({
  349. title: '加载中'
  350. })
  351. const data = {
  352. base: this.form,
  353. other: this.otherForm,
  354. bankList: this.$refs.bankListRef.getValue(),
  355. linkList: this.$refs.linkListRef.getValue(),
  356. };
  357. contactSave(data)
  358. .then((id) => {
  359. uni.hideLoading()
  360. this.back()
  361. })
  362. .catch((e) => {
  363. uni.hideLoading()
  364. });
  365. } catch (error) {
  366. uni.hideLoading()
  367. console.log(error, 'error')
  368. }
  369. },
  370. }
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .required-mark {
  375. color: #FF3333;
  376. margin-right: 4rpx;
  377. }
  378. /deep/.u-cell__body__content {
  379. flex: none;
  380. margin-right: 16rpx;
  381. }
  382. .mainBox {
  383. padding-bottom: 84rpx;
  384. }
  385. .footerButton {
  386. width: 100%;
  387. height: 84rpx;
  388. display: flex;
  389. position: fixed;
  390. bottom: 0;
  391. z-index: 10;
  392. background-color: #fff;
  393. /deep/.u-button {
  394. height: 100%;
  395. }
  396. >view {
  397. flex: 1;
  398. }
  399. }
  400. /deep/.u-button {
  401. // height: 100%;
  402. }
  403. /deep/.u-subsection__item__text {
  404. font-size: 28rpx !important;
  405. }
  406. /deep/.u-cell__body {
  407. // {
  408. // font-size: 26rpx !important;
  409. // }
  410. // padding: 12rpx 12rpx;
  411. .u-cell__title-text,
  412. .input-value,
  413. .uni-input-wrapper {
  414. font-size: 26rpx !important;
  415. }
  416. }
  417. </style>