index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="mainBox">
  3. <div class="title">
  4. <span>{{activeName === 'first' ? '已预约人数:' + tableDataCustomer.length + '人' : '商务负责人:' + tableDataUser.length + '位'}}</span>永天科技-安博会人员信息管理
  5. </div>
  6. <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
  7. <el-tab-pane label="客户信息" name="first"></el-tab-pane>
  8. <el-tab-pane label="接待人信息" name="second"></el-tab-pane>
  9. </el-tabs>
  10. <div class="tableBox">
  11. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  12. <el-form-item label="" v-if="activeName === 'first'">
  13. <el-input v-model="formInline.customer" placeholder="客户姓名/联系电话"></el-input>
  14. </el-form-item>
  15. <el-form-item label="">
  16. <el-input v-model="formInline.user" placeholder="接待人/接待人手机号"></el-input>
  17. </el-form-item>
  18. <el-form-item label="是否已分配" v-if="activeName === 'first'">
  19. <el-select v-model="formInline.distribution" placeholder="">
  20. <el-option label="全部" :value="0"></el-option>
  21. <el-option label="已分配" :value="1"></el-option>
  22. <el-option label="未分配" :value="2"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" @click="onSubmit()">查询</el-button>
  27. <el-button type="primary" @click="exportExcel()">导出</el-button>
  28. <el-button type="primary" @click="type = 'add';dialogUserVisible = true" v-if="activeName === 'second'">新增接待人</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <div class="tableList">
  32. <el-table
  33. :data="tableData"
  34. border
  35. height="100%"
  36. id="userTable"
  37. style="width: 100%">
  38. <template v-if="activeName === 'first'">
  39. <el-table-column prop="name" label="客户姓名" show-overflow-tooltip></el-table-column>
  40. <el-table-column prop="phone" label="联系电话" show-overflow-tooltip></el-table-column>
  41. <el-table-column prop="companyName" label="客户单位名称" show-overflow-tooltip></el-table-column>
  42. <el-table-column prop="post" label="职位" show-overflow-tooltip></el-table-column>
  43. <el-table-column prop="sf" label="省份" show-overflow-tooltip></el-table-column>
  44. <el-table-column prop="dateOfVisit" label="到访日期" show-overflow-tooltip></el-table-column>
  45. <el-table-column prop="accompany" label="随行人数" show-overflow-tooltip>
  46. <template slot-scope="scope">
  47. {{ scope.row.accompany === 1 ? '1-3人' : scope.row.accompany === 2 ? '3-7人' : '7人以上' }}
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="userName" label="接待人" show-overflow-tooltip></el-table-column>
  51. <el-table-column prop="userPhone" label="接待人手机号" show-overflow-tooltip></el-table-column>
  52. </template>
  53. <template v-if="activeName === 'second'">
  54. <el-table-column prop="userName" label="接待人"></el-table-column>
  55. <el-table-column prop="phone" label="接待人手机号"></el-table-column>
  56. <!-- <el-table-column prop="phone" label="登录账号"></el-table-column> -->
  57. <!-- <el-table-column prop="zip" label="接待客户数(人)"></el-table-column> -->
  58. </template>
  59. <el-table-column label="操作" v-if="!isExportExcel">
  60. <template slot-scope="scope">
  61. <template v-if="activeName === 'first'">
  62. <el-button type="text" size="small" v-if="!scope.row.userPhone" @click="type = 'add';currentRow = scope.row;dialogVisible = true">分配接待人</el-button>
  63. <el-button type="text" size="small" v-else @click="type = 'edit';currentRow = scope.row;dialogVisible = true">重新分配</el-button>
  64. </template>
  65. <template v-else-if="activeName === 'second'">
  66. <el-button type="text" size="small" @click="type = 'edit';currentRow = scope.row;dialogUserVisible = true">修改</el-button>
  67. <!-- <el-button type="text" size="small" style="color:red;" @click="deleteClick(scope.row)">删除</el-button> -->
  68. </template>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </div>
  73. </div>
  74. <el-dialog :visible.sync="dialogVisible" :type="type" v-model="currentRow" @getData="getDataCustomer" :tableDataUser="tableDataUser"></el-dialog>
  75. <el-dialog-user :visible.sync="dialogUserVisible" :type="type" v-model="currentRow" @getData="getDataReception"></el-dialog-user>
  76. </div>
  77. </template>
  78. <script>
  79. import elDialog from './dialog';
  80. import elDialogUser from './dialog-user';
  81. import FileSaver from 'file-saver'
  82. import XLSX from 'xlsx'
  83. export default {
  84. components: {
  85. elDialog,
  86. elDialogUser
  87. },
  88. data() {
  89. return {
  90. activeName: "first",
  91. formInline: {
  92. user: "",
  93. customer: "",
  94. distribution: 0,
  95. },
  96. tableData:[],
  97. tableDataUser:[],
  98. tableDataCustomer:[],
  99. dialogVisible:false,
  100. dialogUserVisible:false,
  101. isExportExcel:false,
  102. type:null,
  103. currentRow:{}
  104. };
  105. },
  106. mounted(){
  107. this.getDataCustomer()
  108. this.getDataReception()
  109. },
  110. methods: {
  111. async getDataCustomer(){
  112. let res = await this.$axios.post('/AF/listAppointment')
  113. if(res.data.success){
  114. this.tableDataCustomer = res.data.data
  115. }
  116. this.onSubmit()
  117. },
  118. async getDataReception(){
  119. let res = await this.$axios.post('/AF/listUserInfo')
  120. if(res.data.success){
  121. this.tableDataUser = res.data.data
  122. }
  123. this.onSubmit()
  124. },
  125. handleClick(tab, event) {
  126. console.log(tab, event);
  127. this.onSubmit()
  128. },
  129. // deleteClick(row){
  130. // },
  131. exportExcel () {
  132. this.isExportExcel = true
  133. this.$nextTick(()=>{
  134. //指定想要导出表格的id
  135. let wb = XLSX.utils.table_to_book(document.querySelector('#userTable'))
  136. wb.Sheets.Sheet1['!cols'] = [ {wpx: 100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100}, { wpx:100},]
  137. console.log(wb)
  138. //数据写入
  139. let wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
  140. // console.log(wbout)
  141. try {
  142. //表格的参数
  143. FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'user.xlsx')
  144. } catch (e) {
  145. if(typeof console !== 'undefined') console.log(e, wbout)
  146. }
  147. this.isExportExcel = false
  148. return wbout;
  149. })
  150. },
  151. onSubmit() {
  152. if(this.activeName === 'first'){
  153. this.tableData = this.tableDataCustomer.filter(val=>{
  154. return (!this.formInline.user || (val.userName && val.userName.indexOf(this.formInline.user) !== -1) || (val.userPhone && val.userPhone.indexOf(this.formInline.user) !== -1)) &&
  155. (!this.formInline.customer || val.name.indexOf(this.formInline.customer) !== -1 || val.phone.indexOf(this.formInline.customer) !== -1) &&
  156. (this.formInline.distribution === 0 || (this.formInline.distribution === 1 && !!val.userPhone) || (this.formInline.distribution === 2 && !val.userPhone))
  157. })
  158. } else if(this.activeName === 'second'){
  159. this.tableData = this.tableDataUser.filter(val=>{
  160. return (!this.formInline.user || (val.userName && val.userName.indexOf(this.formInline.user) !== -1) || (val.phone && val.phone.indexOf(this.formInline.user) !== -1))
  161. })
  162. } else{
  163. this.tableData = []
  164. }
  165. },
  166. },
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. .mainBox {
  171. width: 100%;
  172. height: 100%;
  173. display: flex;
  174. flex-direction: column;
  175. padding: 20PX;
  176. box-sizing: border-box;
  177. overflow: hidden;
  178. .title {
  179. text-align: center;
  180. font-size: 20PX;
  181. margin-bottom: 20PX;
  182. span {
  183. float: left;
  184. }
  185. }
  186. .tableBox {
  187. flex: 1;
  188. display: flex;
  189. flex-direction: column;
  190. .tableList{
  191. flex: 1;
  192. }
  193. }
  194. }
  195. </style>