InvitationOfficialActivityData.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div>
  3. <div class="communal-list">
  4. <div class="communal-title">
  5. <div>邀请/公务活动资料</div>
  6. </div>
  7. <div>
  8. <div class="communal-box" style="margin-top: 10px;">
  9. <el-autocomplete style="margin-right: 15px;" class="inline-input" v-model="Country" :fetch-suggestions="querySearchCountry"
  10. placeholder="请输入国家" clearable></el-autocomplete>
  11. <el-autocomplete style="margin-right: 10px;" class="inline-input" v-model="UnitName" :fetch-suggestions="querySearchUnitName"
  12. placeholder="请输入邀请方" clearable></el-autocomplete>
  13. <el-autocomplete style="margin-right: 10px;" class="inline-input" v-model="Contact" :fetch-suggestions="querySearchContact"
  14. placeholder="联系人" clearable></el-autocomplete>
  15. <el-select v-model="Delegation" clearable filterable placeholder="团组名称" style="width: 20%;margin-right: 15px;">
  16. <el-option v-for="(items,index) in restaurantDelegation" :key="index" :label="items.teamName"
  17. :value="items.id">
  18. </el-option>
  19. </el-select>
  20. <el-select style="margin-right: 10px;width:218px;" v-model="CreateUserId" placeholder="录入者" filterable clearable>
  21. <el-option v-for="item in CreateUserList" :key="item.id" :label="item.cnName" :value="item.id">
  22. </el-option>
  23. </el-select>
  24. <el-date-picker style="width:448px;margin-right: 10px;" v-model="InviteTime" type="daterange" align="right" unlink-panels format="yyyy-MM-dd"
  25. value-format="yyyy-MM-dd" range-separator="至" start-placeholder="邀请开始日期" end-placeholder="邀请结束日期"
  26. :picker-options="pickerOptions">
  27. </el-date-picker>
  28. <el-autocomplete class="inline-input" v-model="Field" :fetch-suggestions="querySearchField"
  29. placeholder="领域" clearable></el-autocomplete>
  30. <el-button type="primary" @click="QueryData" style="margin-left: 10px;">查询</el-button>
  31. <div>
  32. <router-link to='/home/OpInvitationOfficialActivityData'>
  33. <el-button type="primary" style="margin-left: 10px;">新增</el-button>
  34. </router-link>
  35. </div>
  36. </div>
  37. <div class="communal-box" style="margin-top: 10px;">
  38. <!-- <el-button type="primary" @click="QueryCount" style="margin-left: 10px;">查询录入数量</el-button> -->
  39. <!-- <div style="display: flex;align-items: center;justify-content: center">
  40. 查询结果:该人员在以上条件共录入<span style="color: red;">{{ dataCount }}</span>条数据
  41. </div> -->
  42. </div>
  43. </div>
  44. <template>
  45. <el-table :data="tableData" border
  46. style="width: 100%;margin-top: 10px;" v-loading="loading" element-loading-text="拼命加载中...">
  47. <el-table-column prop="num" label="序 号" width="55">
  48. <template slot-scope="scope">
  49. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="country" width="100" label="国家">
  53. </el-table-column>
  54. <el-table-column prop="city" label="城市">
  55. </el-table-column>
  56. <el-table-column prop="unitName" label="邀请方名称">
  57. </el-table-column>
  58. <el-table-column prop="field" label="涉及领域">
  59. </el-table-column>
  60. <el-table-column prop="contact" width="100" label="联系人">
  61. </el-table-column>
  62. <el-table-column prop="job" label="职务">
  63. </el-table-column>
  64. <el-table-column prop="tel" width="120px" label="手机">
  65. </el-table-column>
  66. <el-table-column prop="delegationStr" label="关联团组">
  67. <template slot-scope="scope">
  68. <div id="delegationStr">
  69. <el-tooltip v-show="scope.row.delegationStr != ''" class="item" effect="dark"
  70. :content="scope.row.delegationStr" placement="top">
  71. <span v-if="scope.row.delegationStr.length > 9">{{ scope.row.delegationStr.slice(0, 9) + "..."
  72. }}</span>
  73. <span v-else>{{ scope.row.delegationStr }}</span>
  74. <div slot="content">
  75. <div style="width: 300px;">
  76. {{ scope.row.delegationStr }}
  77. </div>
  78. </div>
  79. </el-tooltip>
  80. </div>
  81. </template>
  82. <!-- <template slot-scope="Str">
  83. <div :title="Str.row.delegationStr" class="title">{{ Str.row.delegationStr }}</div>
  84. </template> -->
  85. </el-table-column>
  86. <el-table-column width="80" prop="createUserName" label="录入者">
  87. </el-table-column>
  88. <el-table-column prop="createTime" label="录入时间">
  89. </el-table-column>
  90. <el-table-column label="操作">
  91. <template slot-scope="scope">
  92. <el-button size="mini" @click="upDate(scope.$index, scope.row)">编辑</el-button>
  93. <el-button size="mini" type="danger" @click="del(scope.$index, scope.row)">删除</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. </template>
  98. <div class="block">
  99. <el-pagination align='center' @size-change="handleSizeChange" @current-change="handleCurrentChange"
  100. :current-page="currentPage" :page-sizes="[10, 12, 15, 20]" :page-size="pageSize"
  101. layout="total, sizes, prev, pager, next" :total="dataCount">
  102. </el-pagination>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. export default {
  109. beforeRouteLeave(to, from, next) {
  110. if(to.name!='OpInvitationOfficialActivityData'){
  111. from.meta.keepAlive = false;
  112. }
  113. next()
  114. },
  115. data() {
  116. return {
  117. loading: false,
  118. tableData: [],
  119. tableDatas: [],
  120. currentPage: 1, // 当前页码
  121. pageSize: 10,// 每页的数据条数
  122. dataCount: 0,//总条数
  123. Country: "",
  124. restaurantsCountry: [],
  125. UnitName: "",
  126. restaurantsUnitName: [],
  127. Contact: "",
  128. restaurantContact: [],
  129. Delegation: "",
  130. restaurantDelegation: [],
  131. Field: "",
  132. restaurantField: [],
  133. CreateUserId: "",
  134. CreateUserList: [],
  135. InviteTime: "",
  136. StartCreateTime: "",
  137. EndCreateTime: "",
  138. input: '',
  139. token: '',
  140. pickerOptions: {
  141. shortcuts: [{
  142. text: '最近一周',
  143. onClick(picker) {
  144. const end = new Date();
  145. const start = new Date();
  146. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  147. picker.$emit('pick', [start, end]);
  148. }
  149. }, {
  150. text: '最近一个月',
  151. onClick(picker) {
  152. const end = new Date();
  153. const start = new Date();
  154. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  155. picker.$emit('pick', [start, end]);
  156. }
  157. }, {
  158. text: '最近三个月',
  159. onClick(picker) {
  160. const end = new Date();
  161. const start = new Date();
  162. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  163. picker.$emit('pick', [start, end]);
  164. }
  165. }]
  166. },
  167. }
  168. },
  169. beforeRouteLeave(to,from,next) {
  170. if(to.name=='OpInvitationOfficialActivityData'){
  171. next();
  172. }else{
  173. this.$store.state.Termsofinvitation={};
  174. next();
  175. }
  176. console.log(this.$store.state.Termsofinvitation)
  177. },
  178. methods: {
  179. //每页条数改变时触发 选择一页显示多少行
  180. handleSizeChange(val) {
  181. this.currentPage = 1;
  182. this.pageSize = val;
  183. this.QueryInvitationOfficialActivityData()
  184. },
  185. //当前页改变时触发 跳转其他页
  186. handleCurrentChange(val) {
  187. this.currentPage = val;
  188. this.QueryInvitationOfficialActivityData()
  189. },
  190. //国家搜索框处理
  191. querySearchCountry(queryString, cb) {
  192. //数据去重处理
  193. var arr = this.restaurantsCountry;
  194. for (var i = 0; i < arr.length - 1; i++) {
  195. for (var j = i + 1; j < arr.length; j++) {
  196. if (arr[i].value == arr[j].value) {
  197. arr.splice(j, 1);
  198. //因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
  199. j--;
  200. }
  201. }
  202. }
  203. var restaurantsCountry = arr;
  204. var results = queryString ? restaurantsCountry.filter(this.createFilter(queryString)) : restaurantsCountry;
  205. // 调用 callback 返回建议列表的数据
  206. cb(results);
  207. },
  208. //邀请方搜索框处理
  209. querySearchUnitName(queryString, cb) {
  210. var arr = this.restaurantsUnitName;
  211. for (var i = 0; i < arr.length - 1; i++) {
  212. for (var j = i + 1; j < arr.length; j++) {
  213. if (arr[i].value == arr[j].value) {
  214. arr.splice(j, 1);
  215. //因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
  216. j--;
  217. }
  218. }
  219. }
  220. var restaurantsUnitName = arr;
  221. var results = queryString ? restaurantsUnitName.filter(this.createFilter(queryString)) : restaurantsUnitName;
  222. // 调用 callback 返回建议列表的数据
  223. cb(results);
  224. },
  225. //联系人搜索框处理
  226. querySearchContact(queryString, cb) {
  227. var arr = this.restaurantContact;
  228. for (var i = 0; i < arr.length - 1; i++) {
  229. for (var j = i + 1; j < arr.length; j++) {
  230. if (arr[i].value == arr[j].value) {
  231. arr.splice(j, 1);
  232. //因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
  233. j--;
  234. }
  235. }
  236. }
  237. var restaurantContact = arr;
  238. var results = queryString ? restaurantContact.filter(this.createFilter(queryString)) : restaurantContact;
  239. // 调用 callback 返回建议列表的数据
  240. cb(results);
  241. },
  242. //领域搜索框处理
  243. querySearchField(queryString, cb) {
  244. var arr = this.restaurantField;
  245. for (var i = 0; i < arr.length - 1; i++) {
  246. for (var j = i + 1; j < arr.length; j++) {
  247. if (arr[i].value == arr[j].value) {
  248. arr.splice(j, 1);
  249. //因为数组长度减小1,所以直接 j++ 会漏掉一个元素,所以要 j--
  250. j--;
  251. }
  252. }
  253. }
  254. var restaurantField = arr;
  255. var results = queryString ? restaurantField.filter(this.createFilter(queryString)) : restaurantField;
  256. // 调用 callback 返回建议列表的数据
  257. cb(results);
  258. },
  259. createFilter(queryString) {
  260. return (restaurant) => {
  261. return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  262. };
  263. },
  264. //查询添加vuex
  265. QueryData() {
  266. this.$store.state.Termsofinvitation = {
  267. Country:this.Country,
  268. UnitName:this.UnitName,
  269. Contact:this.Contact,
  270. Delegation:this.Delegation,
  271. CreateUserId:this.CreateUserId,
  272. InviteTime:this.InviteTime,
  273. Field:this.Field,
  274. };
  275. this.currentPage = 1;
  276. this.QueryInvitationOfficialActivityData()
  277. },
  278. //判断全局变量是否有值
  279. estimatevuex(){
  280. console.log(this.$store.state.Termsofinvitation);
  281. this.Country=this.$store.state.Termsofinvitation.Country?this.$store.state.Termsofinvitation.Country:'';
  282. this.UnitName=this.$store.state.Termsofinvitation.UnitName?this.$store.state.Termsofinvitation.UnitName:'';
  283. this.Contact=this.$store.state.Termsofinvitation.Contact?this.$store.state.Termsofinvitation.Contact:'';
  284. this.Delegation=this.$store.state.Termsofinvitation.Delegation?this.$store.state.Termsofinvitation.Delegation:'';
  285. this.CreateUserId=this.$store.state.Termsofinvitation.CreateUserId?this.$store.state.Termsofinvitation.CreateUserId:'';
  286. this.InviteTime=this.$store.state.Termsofinvitation.InviteTime?this.$store.state.Termsofinvitation.InviteTime:'';
  287. this.Field=this.$store.state.Termsofinvitation.Field?this.$store.state.Termsofinvitation.Field:'';
  288. this.currentPage=this.$store.state.Termsofinvitation.pgindex?this.$store.state.Termsofinvitation.pgindex:1;
  289. },
  290. //基础数据
  291. QueryIOAInitData() {
  292. var url = "/api/Resource/QueryIOAInitData"
  293. var that = this
  294. this.$axios({
  295. method: 'post',
  296. url: url,
  297. headers: {
  298. Authorization: 'Bearer ' + that.token
  299. },
  300. data: {
  301. PortType: 1
  302. }
  303. }).then(function (res) {
  304. console.log(res)
  305. if (res.data.code == 200) {
  306. res.data.data.countryData.forEach(function (item, index) {
  307. that.restaurantsCountry.push({
  308. value: item,
  309. });
  310. });
  311. res.data.data.contactData.forEach(function (item, index) {
  312. that.restaurantContact.push({
  313. value: item,
  314. });
  315. });
  316. res.data.data.inviterData.forEach(function (item, index) {
  317. that.restaurantsUnitName.push({
  318. value: item,
  319. });
  320. });
  321. res.data.data.domainData.forEach(function (item, index) {
  322. that.restaurantField.push({
  323. value: item,
  324. });
  325. });
  326. that.restaurantDelegation=res.data.data.groupNameData;
  327. that.CreateUserList=res.data.data.userNameData;
  328. }else{
  329. that.$message.error(res.data.msg);
  330. }
  331. }).catch(function (error) {
  332. that.$message.error(error);
  333. });
  334. },
  335. QueryInvitationOfficialActivityData() {
  336. console.log(this.Delegation)
  337. var CreateUser = 0;
  338. if (this.CreateUserId == "" || this.CreateUserId == undefined || this.CreateUserId == null) {
  339. CreateUser = 0
  340. } else {
  341. CreateUser = this.CreateUserId
  342. }
  343. if (this.InviteTime != "" && this.InviteTime != undefined && this.InviteTime != null) {
  344. this.StartCreateTime = this.InviteTime[0]
  345. this.EndCreateTime = this.InviteTime[1]
  346. } else {
  347. this.StartCreateTime = ""
  348. this.EndCreateTime = ""
  349. }
  350. this.loading = true
  351. var url = "/api/Resource/QueryInvitationOfficialActivityData"
  352. var that = this
  353. this.$axios({
  354. method: 'post',
  355. url: url,
  356. headers: {
  357. Authorization: 'Bearer ' + this.token
  358. },
  359. data: {
  360. portType: 1,
  361. pageIndex: that.currentPage,
  362. pageSize: that.pageSize,
  363. Country: that.Country,
  364. UnitName: that.UnitName,
  365. Contact: that.Contact,
  366. Delegation: that.Delegation.toString(),
  367. Field: that.Field,
  368. CreateUserId: CreateUser,
  369. StartCreateTime: that.StartCreateTime,
  370. EndCreateTime: that.EndCreateTime
  371. }
  372. }).then(function (res) {
  373. console.log(res)
  374. if (res.data.code == 200) {
  375. //#endregion
  376. that.tableData = res.data.data;
  377. that.dataCount=res.data.count;
  378. } else {
  379. that.tableDatas = [];
  380. }
  381. that.loading = false
  382. }).catch(function (error) {
  383. that.loading = false
  384. that.$message.error(error);
  385. });
  386. },
  387. QueryCount() {
  388. var CreateUser = 0;
  389. if (this.CreateUserId == "" || this.CreateUserId == undefined || this.CreateUserId == null) {
  390. CreateUser = 0
  391. } else {
  392. CreateUser = this.CreateUserId
  393. }
  394. if (this.InviteTime != "" && this.InviteTime != undefined && this.InviteTime != null) {
  395. this.StartCreateTime = this.InviteTime[0]
  396. this.EndCreateTime = this.InviteTime[1]
  397. } else {
  398. this.StartCreateTime = ""
  399. this.EndCreateTime = ""
  400. }
  401. this.loading = true
  402. var url = "/api/Resource/QueryInvitationOfficialActivityData"
  403. var that = this
  404. this.$axios({
  405. method: 'post',
  406. url: url,
  407. headers: {
  408. Authorization: 'Bearer ' + this.token
  409. },
  410. data: {
  411. portType: 1,
  412. pageIndex: 0,
  413. pageSize: 0,
  414. Country: '',
  415. UnitName: '',
  416. Contact: '',
  417. Delegation: '',
  418. Field: '',
  419. CreateUserId: CreateUser,
  420. StartCreateTime: that.StartCreateTime,
  421. EndCreateTime: that.EndCreateTime
  422. }
  423. }).then(function (res) {
  424. console.log(res)
  425. if (res.data.code == 200) {
  426. that.tableData = res.data.data;
  427. that.tableDatas = that.tableData
  428. if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
  429. if (that.currentPage > 1) {
  430. that.currentPage = that.currentPage - 1;
  431. }
  432. }
  433. if (that.CreateUserId != 0 && that.CreateUserId != "") {
  434. that.dataCount = that.tableDatas.length
  435. }
  436. } else {
  437. that.tableDatas = [];
  438. }
  439. that.loading = false
  440. }).catch(function (error) {
  441. that.loading = false
  442. that.$message.error("网络错误,请稍后重试");
  443. });
  444. },
  445. del(index, row) {
  446. this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
  447. confirmButtonText: '确定',
  448. cancelButtonText: '取消',
  449. type: 'warning'
  450. }).then(() => {
  451. var url = "/api/Resource/DelInvitationOfficialActivity"
  452. var that = this
  453. this.$axios({
  454. method: 'post',
  455. url: url,
  456. headers: {
  457. Authorization: 'Bearer ' + this.token
  458. },
  459. data: {
  460. Id: row.id,
  461. DeleteUserId: this.userId
  462. }
  463. }).then(function (res) {
  464. console.log(res)
  465. if (res.data.code == 200) {
  466. that.$message({
  467. message: '删除成功',
  468. type: 'success'
  469. });
  470. that.QueryInvitationOfficialActivityData();
  471. } else {
  472. that.$message.error('删除失败!');
  473. }
  474. that.loading = false
  475. }).catch(function (error) {
  476. that.loading = false
  477. that.$message.error("网络错误,请稍后重试");
  478. });
  479. }).catch(() => {
  480. this.$message({
  481. type: 'info',
  482. message: '操作已取消!'
  483. });
  484. });
  485. },
  486. upDate(index, row) {
  487. this.$store.state.Termsofinvitation.pgindex=this.currentPage
  488. this.$router.push({
  489. path: "/home/OpInvitationOfficialActivityData",
  490. query: { id: row.id }
  491. })
  492. },
  493. },
  494. created(){
  495. this.estimatevuex()
  496. },
  497. mounted() {
  498. this.QueryIOAInitData();
  499. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  500. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  501. this.QueryInvitationOfficialActivityData();
  502. }
  503. }
  504. </script>
  505. <style>
  506. .communal-list {
  507. background-color: #fff;
  508. padding: 10px;
  509. box-shadow: 0 0 5px #0005;
  510. border-radius: 10px;
  511. min-height: 830px;
  512. }
  513. .communal-list .block{
  514. margin-top: 15px;
  515. }
  516. .communal-title {
  517. display: flex;
  518. font-size: 17px;
  519. font-weight: 600;
  520. color: #555;
  521. margin-top: 8px;
  522. margin-bottom: 10px;
  523. justify-content: space-between;
  524. align-items: center;
  525. }
  526. .communal-box {
  527. display: flex;
  528. }
  529. .communal-box>button {
  530. margin-left: 10px;
  531. padding: 8px 20px;
  532. }
  533. .title {
  534. width: 80px;
  535. overflow: hidden;
  536. text-overflow: ellipsis;
  537. white-space: nowrap;
  538. cursor: pointer;
  539. }
  540. </style>