pickCustom.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <script setup>
  2. import { reactive, ref, watch } from 'vue'
  3. import { ElMessage } from 'element-plus'
  4. import { useRoute, useRouter } from 'vue-router'
  5. import { customInterence } from '@/api/api.js'
  6. import Contactdia from './components/Contactdialog.vue'
  7. import { useList } from './hooks/customlistHook'
  8. const $router = useRouter()
  9. const $route = useRoute()
  10. const { Role } = useList()
  11. const formRule = {
  12. /* 客户名称 */
  13. custom_name:[
  14. { required: true, message: '客户名称不能为空', trigger: 'blur' },
  15. ],
  16. /* 社会信用码 */
  17. code:[
  18. { required: true, message: '社会信用码不能为空', trigger: 'blur' },
  19. ],
  20. /* 客户状态 */
  21. cuStatus:[
  22. { required: true, message: '客户状态不能为空', trigger: 'blur' },
  23. ],
  24. /* 客户类型 */
  25. custype:[
  26. { required: true, message: '客户类型不能为空', trigger: 'blur' },
  27. ],
  28. /* 行业 */
  29. trade:[
  30. { required: true, message: '行业不能为空', trigger: 'blur' },
  31. ],
  32. /* 客户来源 */
  33. from:[
  34. { required: true, message: '客户来源不能为空', trigger: 'blur' },
  35. ],
  36. /* 销售 */
  37. sales:[
  38. { required: true, message: '所属销售不能为空', trigger: 'blur' },
  39. ],
  40. /* 备注 */
  41. // addreason:[
  42. // { required: true, message: '备注不能为空', trigger: 'blur' },
  43. // ],
  44. }
  45. const companyId = ref($route.query.id)
  46. const activeNames = ref(['1'])//默认展开
  47. const regionType = ref('')
  48. const basicInfo = ref({})//领取的客户基本信息
  49. const pickForm = reactive({
  50. cuStatus:'试用',
  51. custype:'',
  52. trade:'',
  53. from:'',
  54. sales:Number(localStorage.getItem('AdminId'))||'',
  55. addreason:''
  56. })
  57. const authList = ref([])
  58. /* 获取客户详情信息 */
  59. function getDetail() {
  60. customInterence.customDetail({
  61. CompanyId:companyId.value
  62. }).then(res => {
  63. if(res.Ret === 200) {
  64. regionType.value=res.Data.Item.RegionType
  65. let ficcform = res.Data.FiccItem;//ficc添加的信息
  66. let basicform = res.Data.Item;//客户基本信息
  67. let raiform = res.Data.RaiItem;//权益添加的信息
  68. /* 基础表单 */
  69. basicInfo.value = {
  70. custom_name:basicform.CompanyName,
  71. code:basicform.CreditCode,
  72. province:basicform.Province,
  73. city:basicform.City,
  74. CompanyProductId:res.Data.CreateAuth == 1?ficcform.CompanyProductId:raiform.CompanyProductId,
  75. cuStatus:res.Data.CreateAuth == 1?ficcform.Status:raiform.Status,
  76. custype:res.Data.CreateAuth == 1?'ficc':'权益',
  77. trade:res.Data.CreateAuth == 1?ficcform.IndustryName:raiform.IndustryName,
  78. from:res.Data.CreateAuth == 1?ficcform.Source:raiform.Source,
  79. sales:res.Data.CreateAuth == 1?ficcform.SellerName:raiform.SellerName,
  80. addreason:res.Data.CreateAuth == 1?ficcform.Reasons:raiform.Reasons
  81. }
  82. pickForm.custype = basicInfo.value.custype=='ficc'?'权益':'ficc';
  83. if(res.Data.CreateAuth == 1) { //ficc创建客户
  84. /* 处理权限列表格式 */
  85. let auth = [];
  86. ficcform.PermissionList.forEach(item=> {
  87. let obj = {
  88. checkAll:item.CheckList&&item.CheckList.length===item.Items.length?true:false,
  89. isIndeterminate:item.CheckList&&item.CheckList.length>0 && item.CheckList.length<item.Items.length,
  90. ...item,
  91. }
  92. auth.push(obj)
  93. })
  94. authList.value = auth;
  95. }else if (res.Data.CreateAuth == 2){ //权益创建客户
  96. /* 处理权限列表格式 */
  97. let auth = [];
  98. raiform.PermissionList.forEach(item=> {
  99. let obj = {
  100. checkAll:item.CheckList&&item.CheckList.length===item.Items.length?true:false,
  101. isIndeterminate:item.CheckList&&item.CheckList.length>0 && item.CheckList.length<item.Items.length,
  102. ...item,
  103. }
  104. auth.push(obj)
  105. })
  106. authList.value = auth;
  107. }
  108. getAuthBasic();
  109. }
  110. })
  111. }
  112. getDetail()
  113. /* 获取基本权限信息 */
  114. const authListRai = ref([])
  115. function getAuthBasic() {
  116. customInterence.authList({
  117. NoUpgrade:true
  118. }).then(res => {
  119. if(res.Ret === 200) {
  120. let newArr = [];
  121. res.Data.List.length&&res.Data.List.forEach(item => {
  122. let obj = {
  123. checkAll:false,
  124. isIndeterminate:item.ClassifyName === '宏观经济'?true:false,
  125. ...item,
  126. }
  127. newArr.push(obj)
  128. })
  129. authListRai.value = newArr;
  130. }
  131. })
  132. }
  133. /* 获取客户来源数据 */
  134. const fromArr = ref([])//客户来源
  135. function getCustomerSourceList(){
  136. customInterence.customerSourceList().then(res=>{
  137. if(res.Ret===200){
  138. fromArr.value = res.Data.List
  139. }
  140. })
  141. }
  142. getCustomerSourceList()
  143. /* 获取销售 */
  144. const salesArr = ref([])
  145. function getSale() {
  146. customInterence.saleslist().then(res => {
  147. if(res.Ret === 200) {
  148. salesArr.value = res.Data.List;
  149. }
  150. })
  151. }
  152. getSale()
  153. /* 根据类型获取行业 */
  154. const tradeArr = ref([])
  155. function getIndustry() {
  156. customInterence.getindustry({
  157. Classify:pickForm.custype
  158. }).then(res => {
  159. if(res.Ret === 200) {
  160. tradeArr.value = res.Data.List || [];
  161. }
  162. })
  163. }
  164. /* 选择行业先校验是否选择了客户类型提示 */
  165. function slideTrade(e) {
  166. if(!pickForm.custype) {
  167. ElMessage.warning('请先选择客户类型!')
  168. }
  169. }
  170. /* 确定 */
  171. const pickFormRef = ref(null)
  172. const diaform = ref({
  173. name:'',
  174. sex:1,
  175. telCode:'86',
  176. tel1:'',
  177. tel2:'',
  178. mail:'',
  179. post:'',
  180. desiger:'',
  181. depart:'',
  182. carte:'',
  183. Source:'pick_custom',
  184. })
  185. const isAddContact = ref(false)//是否添加联系人
  186. const isShowclose = ref(false)//是否显示取消
  187. function saveHandle() {
  188. pickFormRef.value.validate((valid) => {
  189. if (valid) {
  190. //判断是否选择了权限,默认勾选的也算上
  191. let checkArr = [];
  192. authListRai.value.forEach(item => {
  193. checkArr.push(...item.CheckList)
  194. })
  195. console.log(checkArr);
  196. if(!checkArr.length) {
  197. ElMessage.warning('请选择权限')
  198. return
  199. }
  200. isAddContact.value = true;
  201. }
  202. })
  203. }
  204. /* 添加联系人之后再领取客户 */
  205. function cancelConcatdia(type) {
  206. isAddContact.value = false;
  207. if(type === 1) {
  208. let checkArr = [];
  209. authListRai.value.forEach(item => {
  210. if(item.CheckList.length) {
  211. checkArr.push(item.CheckList)
  212. }
  213. })
  214. if(checkArr.length) {
  215. let PermissionIds = checkArr.flat(2).join(',');
  216. let params = {
  217. CompanyId: Number(companyId.value),
  218. IndustryId: pickForm.trade,
  219. Reasons: pickForm.addreason,
  220. SellsId: pickForm.sales,
  221. Source: pickForm.from,
  222. Status: pickForm.cuStatus,
  223. CompanyType:pickForm.custype,
  224. PermissionIds
  225. }
  226. customInterence.Pick(params).then(res => {
  227. if(res.Ret === 200) {
  228. ElMessage.success(res.Msg);
  229. $router.go(-2);
  230. }
  231. })
  232. }else {
  233. ElMessage.warning('权限设置不能为空')
  234. }
  235. }else {
  236. ElMessage.warning('领取失败')
  237. }
  238. }
  239. /* 取消 */
  240. function cancelPick() {
  241. $router.go(-1);
  242. }
  243. /* 选择全选或取消全选 */
  244. function handleCheckAll(item) {
  245. // 取到所有的子菜单id
  246. let ids = item.Items.map(item =>{
  247. return item.ChartPermissionId
  248. })
  249. item.CheckList = item.checkAll ? ids : [];
  250. item.isIndeterminate = false;
  251. }
  252. /* 复选框組选中时 */
  253. function handleChecked(item) {
  254. let len = item.CheckList.length;
  255. item.checkAll = len === item.Items.length;
  256. item.isIndeterminate = len > 0 && len < item.Items.length;
  257. }
  258. watch(
  259. () => pickForm.custype,
  260. () => {
  261. getIndustry();
  262. }
  263. )
  264. </script>
  265. <template>
  266. <div class="pickCustom_container">
  267. <div class="left_form_cont">
  268. <ul class="detail_item">
  269. <li>
  270. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">客户名称</label>
  271. <span style="width:400px;display:inline-block;">{{basicInfo.custom_name}}</span>
  272. </li>
  273. <li>
  274. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">社会信用码</label>
  275. <span style="width:400px;display:inline-block;">{{basicInfo.code}}</span>
  276. </li>
  277. <li>
  278. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">客户地址</label>
  279. <span style="width:400px;display:inline-block;">{{basicInfo.province+'/'+basicInfo.city}}</span>
  280. </li>
  281. <li>
  282. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">客户状态</label>
  283. <el-radio border :label="basicInfo.cuStatus" style="width:184px;marignRight:200px;" v-model="basicInfo.cuStatus">{{basicInfo.cuStatus=='试用'?'试用(2个月)':basicInfo.cuStatus}}</el-radio>
  284. </li>
  285. <li>
  286. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">客户类型</label>
  287. <span style="width:400px;display:inline-block;">{{basicInfo.custype}}</span>
  288. </li>
  289. <li>
  290. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">行业</label>
  291. <span style="width:400px;display:inline-block;">{{basicInfo.trade}}</span>
  292. </li>
  293. <li>
  294. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">客户来源</label>
  295. <span style="width:400px;display:inline-block;">{{basicInfo.from}}</span>
  296. </li>
  297. <li>
  298. <label style="marginRight:60px;width:80px;textAlign:right;display:inline-block;">所属销售</label>
  299. <span style="width:400px;display:inline-block;">{{basicInfo.sales}}</span>
  300. </li>
  301. <li class="textarea_item" style="width:90%;paddingLeft:15px;">
  302. <label style="display:block;marginBottom:20px;fontSize:16px;position:relative;">
  303. 权限设置
  304. </label>
  305. <ul class="menu_lists">
  306. <li v-for="item in authList" :key="item.ClassifyName" class="menu_item">
  307. <el-checkbox :indeterminate="item.isIndeterminate" v-model="item.checkAll" disabled style="marginRight:30px;fontWeight:bold;">{{item.ClassifyName+':'}}</el-checkbox>
  308. <el-checkbox-group v-model="item.CheckList" disabled>
  309. <el-checkbox v-for="list in item.Items" :label="list.ChartPermissionId" :key="list.ChartPermissionId" class="list_item">{{list.PermissionName}}</el-checkbox>
  310. </el-checkbox-group>
  311. </li>
  312. </ul>
  313. </li>
  314. </ul>
  315. <!-- 可折叠form -->
  316. <el-collapse v-model="activeNames" style="width:93%;marginTop:50px;">
  317. <el-collapse-item :title="basicInfo.custype=='ficc'?'权益属性配置':'ficc属性配置'" name="1">
  318. <el-form
  319. @submit.prevent
  320. inline
  321. :model="pickForm"
  322. :rules="formRule"
  323. hide-required-asterisk
  324. ref="pickFormRef"
  325. label-width="100px"
  326. class="demo-ruleForm">
  327. <el-form-item label="客户来源" prop="from" style="marginRight:120px;">
  328. <i style="color:#f00;fontSize:20px;position:absolute;left:-90px;top:10%;">*</i>
  329. <el-select v-model="pickForm.from" placeholder="请选择客户来源" style="width:400px;" filterable>
  330. <el-option
  331. v-for="item in fromArr"
  332. :key="item.SourceId"
  333. :label="item.SourceName"
  334. :value="item.SourceName">
  335. </el-option>
  336. </el-select>
  337. </el-form-item>
  338. <el-form-item label="客户状态" prop="cuStatus">
  339. <i style="color:#f00;fontSize:20px;position:absolute;left:-90px;top:10%;">*</i>
  340. <el-radio-group v-model="pickForm.cuStatus" size="default">
  341. <el-radio border label="试用" style="width:184px;">试用(2个月)</el-radio>
  342. </el-radio-group>
  343. </el-form-item>
  344. <el-form-item label="客户类型" prop="custype" style="marginRight:120px;">
  345. <i style="color:#f00;fontSize:20px;position:absolute;left:-90px;top:10%;">*</i>
  346. <span style="width:400px;display:inline-block;fontSize:16px;color:#666;">{{pickForm.custype}}</span>
  347. </el-form-item>
  348. <el-form-item label="行业" prop="trade">
  349. <i style="color:#f00;fontSize:20px;position:absolute;left:-58px;top:10%;">*</i>
  350. <el-select v-model="pickForm.trade" placeholder="请选择行业" style="width:400px;">
  351. <el-option
  352. v-for="item in tradeArr"
  353. :key="item"
  354. :label="item.IndustryName"
  355. :value="item.IndustryId">
  356. </el-option>
  357. </el-select>
  358. </el-form-item>
  359. <el-form-item label="所属销售" prop="sales">
  360. <i style="color:#f00;fontSize:20px;position:absolute;left:-90px;top:10%;">*</i>
  361. <el-select v-model="pickForm.sales" placeholder="请选择销售" style="width:400px;" filterable :disabled="Role=='rai_seller'||Role=='ficc_seller'">
  362. <el-option
  363. v-for="item in salesArr"
  364. :key="item.AdminId"
  365. :label="item.RealName"
  366. :value="item.AdminId">
  367. </el-option>
  368. </el-select>
  369. </el-form-item>
  370. <el-form-item class="textarea_item" style="width:96%;paddingLeft:26px;">
  371. <label style="display:block;marginBottom:20px;fontSize:16px;position:relative;color:#666;">
  372. <i style="color:#f00;fontSize:20px;position:absolute;left:-15px;top:10%;">*</i>
  373. 权限设置
  374. </label>
  375. <ul class="menu_lists">
  376. <li v-for="item in authListRai" :key="item.ClassifyName" class="menu_item">
  377. <el-checkbox :indeterminate="item.isIndeterminate" v-model="item.checkAll" :disabled="item.ClassifyName === '宏观经济'" @change="handleCheckAll(item)" style="marginRight:30px;fontWeight:bold;">{{item.ClassifyName+':'}}</el-checkbox>
  378. <el-checkbox-group v-model="item.CheckList" @change="handleChecked(item)">
  379. <el-checkbox v-for="list in item.Items" :label="list.ChartPermissionId" :key="list.ChartPermissionId" class="list_item" :disabled="list.ChartPermissionId==1">{{list.PermissionName}}</el-checkbox>
  380. </el-checkbox-group>
  381. </li>
  382. </ul>
  383. </el-form-item>
  384. </el-form>
  385. </el-collapse-item>
  386. </el-collapse>
  387. <div style="display:flex;justify-content:center;margin:40px 0 0;">
  388. <el-button type="primary" style="width:80px;marginRight:24px;" @click="saveHandle">确定</el-button>
  389. <el-button type="primary" plain style="width:80px;" @click="cancelPick">取消</el-button>
  390. </div>
  391. </div>
  392. <!-- 添加联系人弹窗 -->
  393. <Contactdia
  394. :id="companyId"
  395. :title="'新增联系人'"
  396. :userForm="diaform"
  397. :custom_name="basicInfo.custom_name"
  398. :needCard="true"
  399. :isPickOther="true"
  400. :isShowclose="isShowclose"
  401. :regionType="regionType"
  402. :isAddContact="isAddContact"
  403. @cancel="cancelConcatdia"
  404. />
  405. </div>
  406. </template>
  407. <style scoped lang="scss">
  408. .pickCustom_container {
  409. padding:30px 40px 60px 60px;
  410. background: #fff;
  411. position: relative;
  412. border: 1px solid #ECECEC;
  413. border-radius: 4px;
  414. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  415. font-size: 16px;
  416. color: #666;
  417. /* reset */
  418. :deep(.el-collapse) {
  419. border: none;
  420. .el-collapse-item__header {
  421. display: block;
  422. border: none;
  423. font-size: 16px;
  424. color: #333;
  425. margin-bottom: 20px;
  426. text-align: left;
  427. }
  428. .el-collapse-item__wrap {
  429. border: none;
  430. }
  431. }
  432. :deep(.textarea_item .el-form-item__content) {
  433. width: 100%;
  434. }
  435. :deep(.el-form-item .el-checkbox-group) {
  436. height: 40px;
  437. line-height: 40px;
  438. }
  439. /* */
  440. .detail_item {
  441. display: flex;
  442. align-items: center;
  443. flex-wrap: wrap;
  444. li {
  445. font-size: 16px;
  446. color: #666;
  447. margin-bottom: 30px;
  448. min-width: 545px;
  449. margin-right: 30px;
  450. &:last-child {
  451. margin-bottom: 0;
  452. }
  453. // display: flex;
  454. // align-items: center;
  455. }
  456. }
  457. .menu_lists {
  458. width: 100%;
  459. padding: 40px 18px;
  460. border: 1px dashed #AAB4CC;
  461. border-radius: 4px;
  462. .menu_item {
  463. display: flex;
  464. // align-items: center;
  465. margin-bottom: 40px;
  466. &:last-child {
  467. margin-bottom: 0;
  468. }
  469. .list_item {
  470. margin-right: 30px;
  471. &:last-child {
  472. margin-right: 0;
  473. }
  474. }
  475. }
  476. }
  477. }
  478. </style>