editCustomEn.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <div id="edit-custom-container">
  3. <!-- 编辑客户区域 -->
  4. <div class="edit-custom-zone">
  5. <el-form :model="editForm" inline size="medium" ref="editForm" style="flex:1">
  6. <el-form-item label="客户名称" prop="CompanyName" :rules="{required:true,message:'客户名称不能为空',trigger:'blur'}">
  7. <el-input v-model="editForm.CompanyName" placeholder="请输入客户名称" style="width: 337px;" :disabled="viewType=='detail'"></el-input>
  8. </el-form-item>
  9. <el-form-item label="所属国家" prop="CountryCode" :rules="{required:true,message:'所属国家不能为空',trigger:'change'}">
  10. <el-select v-model="editForm.CountryCode" placeholder="请选择" filterable style="width: 337px;" :disabled="viewType=='detail'">
  11. <el-option :label="item.cnName" :value="item.code" v-for="item in countryData" :key="item.code" >
  12. <div style="display: flex;justify-content: space-between;">
  13. <span>{{ item.cnName }}</span>
  14. <span style="color: #8492a6; font-size: 13px">{{ item.code }}</span>
  15. </div>
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <br/>
  20. <el-form-item label="所属销售" prop="SellerId" :rules="{required:true,message:'所属销售不能为空',trigger:'change'}">
  21. <el-select v-model="editForm.SellerId" placeholder="请选择" style="width: 337px;" filterable :disabled="viewType=='detail'">
  22. <el-option :label="item.RealName" :value="item.AdminId" v-for="item in sellerList" :key="item.AdminId"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <div class="variety-set-wrap">
  26. <el-form-item label="权限配置" :rules="{required:true,message:'请选择权限',trigger:'change'}">
  27. <div class="con">
  28. <reportVarietyEnSet ref="varietyIns" v-if="editForm.CompanyName||$route.path == '/addCustomEn'" :checked="varietyOpts" :disabled="viewType=='edit'?false:true"/>
  29. </div>
  30. </el-form-item>
  31. </div>
  32. </el-form>
  33. <div class="edit-zone-options">
  34. <template v-if="viewType=='edit'">
  35. <el-button type="primary" style="width:120px;margin-right: 6px;" size="medium" @click="editSubmit">保存</el-button>
  36. <el-button style="width:120px;" size="medium" @click="editCancel">取消</el-button>
  37. </template>
  38. <template v-else>
  39. <el-button type="primary" style="width:120px;margin-right: 6px;" size="medium" @click="toEdit">编辑</el-button>
  40. <el-button style="width:120px;" size="medium" @click="customDelete">删除</el-button>
  41. </template>
  42. </div>
  43. </div>
  44. <!-- 联系人区域 -->
  45. <div class="contacts-zone" v-if="$route.path != '/addCustomEn'">
  46. <div class="contacts-options-zone">
  47. <!-- 联系人操作区域 -->
  48. <div class="options-zone-buttons">
  49. <el-button type="primary" style="margin-right: 16px;" @click="addContacts">添加联系人</el-button>
  50. <el-upload action="#" :show-file-list="false" style="display: inline;" :http-request="templateUpload"
  51. accept=".xls,.xlsx">
  52. <el-button type="primary" style="width: 112px;margin-right: 26px;">批量导入</el-button>
  53. </el-upload>
  54. <a href="https://hzstatic.hzinsights.com/static/admin/excel/英文联系人批量导入模板.xlsx" download>批量导入模板</a>
  55. </div>
  56. <div>
  57. <el-input v-model="searchParams.Keywords" placeholder="请输入联系人姓名/邮箱" @input="getList('search')"
  58. style="width: 520px;" clearable >
  59. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  60. </el-input>
  61. </div>
  62. </div>
  63. <!-- 联系人列表区域 -->
  64. <div class="contacts-table-zone">
  65. <div style="overflow: auto;flex-grow: 1;">
  66. <el-table :data="contactsList" border @sort-change="clickTimesSortChange">
  67. <el-table-column label="联系人姓名" align="center" prop="Name">
  68. <template slot-scope="{row}">
  69. <img
  70. :src="$icons.card"
  71. alt=""
  72. style="width:17px;cursor:pointer;marginRight:5px;"
  73. v-if="row.BusinessCardUrl"
  74. @click="reviewCard(row.BusinessCardUrl)"
  75. />
  76. <span>{{row.Name}}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="注册公司" align="center" prop="CompanyName">
  80. <template slot-scope="{row}">
  81. {{row.CompanyName || '-'}}
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="手机号" align="center" prop="Mobile">
  85. <template slot-scope="{row}">
  86. {{row.CountryCode}}-{{row.Mobile}}
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="注册时间" align="center" prop="RegisterTime">
  90. <template slot-scope="{row}">
  91. {{row.RegisterTime || '-'}}
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="邮箱地址" align="center" prop="Email">
  95. <template slot-scope="{row}">
  96. {{row.Email}}
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="累计点击量" align="center" sortable="custom" width="120"
  100. prop="ViewTotal">
  101. <template slot-scope="{row}">
  102. <span class="table-options" @click="clickTimesDetail(row)" v-if="row.ViewTotal!=0">{{row.ViewTotal}}</span>
  103. <span v-else>{{row.ViewTotal}}</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="添加时间" align="center" prop="CreateTime" >
  107. <template slot-scope="{row}">
  108. {{row.CreateTime}}
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="状态" align="center" prop="Enabled" >
  112. <template slot-scope="{row}">
  113. <span :class="[row.Enabled===0?'hint':'']">{{row.Enabled?'启用':'禁用'}}</span>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="操作" align="center" width="120">
  117. <template slot-scope="{row}">
  118. <span class="table-options" style="margin-right: 12px;" @click="editContacts(row)">编辑</span>
  119. <span class="table-options" style="margin-right: 12px;" @click="changeStatus(row)">{{row.Enabled?'禁用':'启用'}}</span>
  120. <span class="table-options" @click="delContacts(row)" style="color:#D1433A;">删除</span>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. </div>
  125. <!-- 页数选择器 -->
  126. <m-page
  127. v-show="total!=0"
  128. style="float: none;text-align: right;margin-top: 20px;"
  129. :page_no="searchParams.CurrentIndex"
  130. :pageSize="searchParams.PageSize"
  131. :total="total"
  132. @handleCurrentChange="pageChange"
  133. />
  134. </div>
  135. </div>
  136. <!-- 累计点击量详情弹窗 -->
  137. <click-number-detail :visible.sync="showClickTimesDia"
  138. :name="clickTimesDetailItem.contactsName" type="contacts"
  139. :id="clickTimesDetailItem.contactsId"></click-number-detail>
  140. <!-- 添加/编辑联系人 -->
  141. <contact-save-en-dia :contactsSubmitForm="contactsSubmitForm" :title="dialogTitle" :showAddDia.sync="showAddDia"
  142. :companyId="searchParams.CompanyId" @updateList="updateList"></contact-save-en-dia>
  143. <!-- 图片预览 -->
  144. <el-image-viewer
  145. v-if="showViewer"
  146. :on-close="closeViewer"
  147. :url-list="[imgView]" />
  148. </div>
  149. </template>
  150. <script>
  151. import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
  152. import mPage from '@/components/mPage.vue';
  153. import clickNumberDetail from "../compontents/clickNumberDetailDia.vue"
  154. import ContactSaveEnDia from './components/ContactSaveEnDia.vue';
  155. import country from "@/utils/countryData"
  156. import { customInterence } from '@/api/api.js'
  157. import reportVarietyEnSet from '@/components/reportVarietyEnSet.vue'
  158. export default {
  159. name:"editCustomEn",
  160. components:{mPage,clickNumberDetail,ElImageViewer,ContactSaveEnDia,reportVarietyEnSet},
  161. watch:{
  162. 'editForm.CountryCode':{
  163. handler(newVal){
  164. this.editForm.Country = newVal?this.countryData.find(item => item.code == newVal).cnName:''
  165. }
  166. }
  167. },
  168. data() {
  169. // 不监听 countryData 数组里面的数据 - 即国家数据
  170. this.countryData=country
  171. return {
  172. // edit 编辑英文客户 英文客户详情
  173. viewType:"edit",
  174. editForm:{
  175. CompanyId:0,
  176. CompanyName:"",
  177. CountryCode:"",
  178. Country:"",
  179. SellerId:""
  180. },
  181. // 联系人列表搜索参数
  182. searchParams:{
  183. CompanyId:0,
  184. CurrentIndex:1,
  185. PageSize:8,
  186. SortType:"",
  187. Keywords:""
  188. },
  189. total:0,
  190. // 联系人列表
  191. contactsList:[],
  192. // 销售列表
  193. sellerList:[],
  194. // ------------------累计点击量弹窗
  195. showClickTimesDia:false,
  196. clickTimesDetailItem:{
  197. contactsName:"",
  198. contactsId:""
  199. },
  200. // --------------------添加/编辑弹窗
  201. dialogTitle:"添加联系人",
  202. showAddDia:false,
  203. contactsSubmitForm:{},
  204. imgView:'',
  205. showViewer:false,
  206. varietyOpts:[],
  207. }
  208. },
  209. created() {
  210. if(this.$route.path == '/addCustomEn'){
  211. this.getSellerList()
  212. return
  213. }
  214. if(!this.$route.query.companyId){
  215. // 无客户信息
  216. this.$router.replace('/customListEn')
  217. return
  218. }
  219. // 判断页面的类型
  220. this.viewType=this.$route.path == '/detailCustomEn'?'detail':'edit'
  221. this.editForm.CompanyId=this.searchParams.CompanyId=parseInt(this.$route.query.companyId)
  222. this.getSellerList()
  223. this.customDetail()
  224. this.getList()
  225. },
  226. methods: {
  227. // 获取销售列表
  228. getSellerList(){
  229. customInterence.saleslist({SellerType:0}).then(res=>{
  230. if(res.Ret == 200){
  231. this.sellerList = res.Data.List || []
  232. }
  233. })
  234. },
  235. // 客户详情
  236. customDetail(){
  237. customInterence.customDetailEn({CompanyId:this.editForm.CompanyId}).then(res=>{
  238. if(res.Ret == 200){
  239. this.editForm.CompanyName=res.Data.CompanyName
  240. this.editForm.Country=res.Data.Country
  241. this.editForm.CountryCode=res.Data.CountryCode
  242. this.editForm.SellerId=res.Data.SellerId
  243. this.varietyOpts=res.Data.EnPermissions
  244. }else{
  245. this.$router.replace('/customListEn')
  246. }
  247. })
  248. },
  249. getList(type=''){
  250. if(type=="search"){
  251. this.searchParams.CurrentIndex=1
  252. }
  253. customInterence.getContactsListEn(this.searchParams).then(res=>{
  254. if(res.Ret == 200){
  255. this.contactsList = res.Data.List || []
  256. this.total = res.Data.Paging.Totals
  257. }
  258. })
  259. },
  260. // 重置列表和搜索项
  261. refreshList(){
  262. this.searchParams.SortType=""
  263. this.searchParams.Keywords=""
  264. this.searchParams.CurrentIndex=1
  265. this.getList()
  266. },
  267. pageChange(page_no){
  268. this.searchParams.CurrentIndex=page_no
  269. this.getList()
  270. },
  271. updateList(type){
  272. type=='refresh'?this.getList():this.refreshList()
  273. },
  274. // 修改提交
  275. editSubmit(){
  276. this.$refs.editForm.validate(valid=>{
  277. if(valid){
  278. customInterence.addCustomEn({
  279. ...this.editForm,
  280. EnPermissions:this.$refs.varietyIns.checkedItems||[],
  281. Nation:this.editForm.Country
  282. }).then(res=>{
  283. if(res.Ret == 200){
  284. let messageEle=this.$message.success(this.$route.path == '/addCustomEn'?'添加客户成功':'编辑客户成功')
  285. setTimeout(()=>{
  286. messageEle.close()
  287. this.editCancel()
  288. },1000)
  289. }
  290. })
  291. }
  292. })
  293. },
  294. // 取消修改
  295. editCancel(){
  296. //this.$router.back()
  297. this.$router.push({path:'/customListEn'})
  298. },
  299. // -----------------------英文客户详情独有方法
  300. // 去编辑用户
  301. toEdit(){
  302. this.$router.replace({path:'/editCustomEn',query:{companyId:this.editForm.CompanyId}})
  303. this.viewType="edit"
  304. },
  305. // 删除客户
  306. customDelete(){
  307. this.$confirm(`是否确认删除客户<span style="color:#409EFF">${this.editForm.CompanyName}</span>,并删除该客户下所有的联系人?`,"操作提示",
  308. {
  309. type:"warning",
  310. dangerouslyUseHTMLString:true,
  311. confirmButtonText: "确定",
  312. cancelButtonText: "取消"
  313. }).then(res=>{
  314. customInterence.delCustomEn({CompanyId:this.editForm.CompanyId}).then(res=>{
  315. if(res.Ret == 200){
  316. let hint=this.$message.success("删除客户成功")
  317. setTimeout(()=>{
  318. hint.close()
  319. //this.$router.back()
  320. this.$router.push({path:'/customListEn'})
  321. },1000)
  322. }
  323. })
  324. }).catch(() => {});
  325. },
  326. // 累计点击量排序
  327. clickTimesSortChange({order}){
  328. this.searchParams.SortType=order=="ascending"?'2':order=="descending"?'1':''
  329. this.getList()
  330. },
  331. //累计点击量详情
  332. clickTimesDetail(row){
  333. this.clickTimesDetailItem.contactsName = row.Name
  334. this.clickTimesDetailItem.contactsId = row.Id
  335. this.showClickTimesDia=true
  336. },
  337. // -------------------------------------添加/编辑联系人
  338. //添加联系人
  339. addContacts(){
  340. this.contactsSubmitForm={}
  341. this.dialogTitle="添加联系人"
  342. this.showAddDia=true
  343. },
  344. // 编辑联系人
  345. editContacts(row){
  346. this.contactsSubmitForm=row
  347. this.dialogTitle="编辑联系人"
  348. this.showAddDia=true
  349. },
  350. // -----------------------------上传批量导入模板
  351. templateUpload(file){
  352. let formData = new FormData()
  353. formData.append('File',file.file)
  354. formData.append('CompanyId',this.editForm.CompanyId)
  355. customInterence.importContactsEn(formData).then(res=>{
  356. if(res.Ret == 200){
  357. this.$message.success('批量导入成功')
  358. this.refreshList()
  359. }
  360. })
  361. },
  362. // 删除客户
  363. delContacts(row){
  364. this.$confirm(`是否确认删除联系人<span style="color:#409EFF">${row.Name}</span>?`,"操作提示",
  365. {
  366. type:"warning",
  367. dangerouslyUseHTMLString:true,
  368. confirmButtonText: "确定",
  369. cancelButtonText: "取消",
  370. }).then(res=>{
  371. customInterence.delContactsEn({EmailId:row.Id}).then(res=>{
  372. if(res.Ret == 200){
  373. this.$message.success("删除联系人成功")
  374. this.getList()
  375. }
  376. })
  377. }).catch(() => {});
  378. },
  379. //启用禁用联系人
  380. changeStatus(row){
  381. customInterence.editEnabledEn({
  382. EmailId:row.Id,
  383. Enabled:row.Enabled===1?0:1
  384. }).then(res=>{
  385. if(res.Ret!==200) return
  386. this.$message.success('操作成功')
  387. this.getList()
  388. })
  389. },
  390. /* 预览名片 */
  391. reviewCard(card) {
  392. console.log('aaa');
  393. this.showViewer = true;
  394. this.imgView = card;
  395. },
  396. /* 关闭预览 */
  397. closeViewer() {
  398. this.imgView = '';
  399. this.showViewer = false;
  400. },
  401. },
  402. }
  403. </script>
  404. <style lang="scss" scoped>
  405. #edit-custom-container{
  406. .edit-custom-zone{
  407. padding: 30px 30px 10px 30px;
  408. display: flex;
  409. justify-content: space-between;
  410. border: 1px solid #ECECEC;
  411. background-color: white;
  412. border-radius: 2px;
  413. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  414. margin-bottom: 20px;
  415. .edit-zone-options{
  416. min-width: 260px;
  417. }
  418. }
  419. .contacts-zone{
  420. border: 1px solid #ECECEC;
  421. background-color: white;
  422. border-radius: 2px;
  423. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  424. padding: 30px;
  425. box-sizing: border-box;
  426. display: flex;
  427. flex-direction: column;
  428. .contacts-options-zone{
  429. display: flex;
  430. justify-content: space-between;
  431. flex-wrap: wrap;
  432. margin-bottom: 20px;
  433. .options-zone-buttons{
  434. margin-bottom: 10px;
  435. a{
  436. cursor: pointer;
  437. font-size: 16px;
  438. color: #409EFF;
  439. line-height: 40px;
  440. }
  441. }
  442. }
  443. .contacts-table-zone{
  444. .table-options{
  445. cursor: pointer;
  446. font-size: 14px;
  447. color: #409EFF;
  448. }
  449. }
  450. }
  451. .hint{
  452. color: red;
  453. }
  454. }
  455. </style>
  456. <style lang="scss">
  457. #edit-custom-container{
  458. .el-form-item{
  459. margin-right: 100px;
  460. }
  461. .el-form-item:nth-child(2){
  462. margin-right: 50px;
  463. }
  464. .el-form-item__label{
  465. color: black;
  466. }
  467. .img_item {
  468. position: relative;
  469. width: 280px;
  470. height: 180px;
  471. border-radius: 4px;
  472. }
  473. .variety-set-wrap{
  474. .el-form-item{
  475. width: 100%;
  476. .el-form-item__content{
  477. display: block;
  478. .con{
  479. border: 1px dashed #DCDFE6;
  480. border-radius: 4px;
  481. padding: 20px;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. </style>