add.vue 13 KB

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