add.vue 12 KB

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