editCustomEn.vue 15 KB

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