InvitationOfficialActivityData.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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 height="680" :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. this.pageSize=this.$store.state.Termsofinvitation.pageSize?this.$store.state.Termsofinvitation.pageSize:10;
  290. },
  291. //基础数据
  292. QueryIOAInitData() {
  293. var url = "/api/Resource/QueryIOAInitData"
  294. var that = this
  295. this.$axios({
  296. method: 'post',
  297. url: url,
  298. headers: {
  299. Authorization: 'Bearer ' + that.token
  300. },
  301. data: {
  302. PortType: 1
  303. }
  304. }).then(function (res) {
  305. console.log(res)
  306. if (res.data.code == 200) {
  307. res.data.data.countryData.forEach(function (item, index) {
  308. that.restaurantsCountry.push({
  309. value: item,
  310. });
  311. });
  312. res.data.data.contactData.forEach(function (item, index) {
  313. that.restaurantContact.push({
  314. value: item,
  315. });
  316. });
  317. res.data.data.inviterData.forEach(function (item, index) {
  318. that.restaurantsUnitName.push({
  319. value: item,
  320. });
  321. });
  322. res.data.data.domainData.forEach(function (item, index) {
  323. that.restaurantField.push({
  324. value: item,
  325. });
  326. });
  327. that.restaurantDelegation=res.data.data.groupNameData;
  328. that.CreateUserList=res.data.data.userNameData;
  329. }else{
  330. that.$message.error(res.data.msg);
  331. }
  332. }).catch(function (error) {
  333. that.$message.error(error);
  334. });
  335. },
  336. QueryInvitationOfficialActivityData() {
  337. console.log(this.Delegation)
  338. var CreateUser = 0;
  339. if (this.CreateUserId == "" || this.CreateUserId == undefined || this.CreateUserId == null) {
  340. CreateUser = 0
  341. } else {
  342. CreateUser = this.CreateUserId
  343. }
  344. if (this.InviteTime != "" && this.InviteTime != undefined && this.InviteTime != null) {
  345. this.StartCreateTime = this.InviteTime[0]
  346. this.EndCreateTime = this.InviteTime[1]
  347. } else {
  348. this.StartCreateTime = ""
  349. this.EndCreateTime = ""
  350. }
  351. this.loading = true
  352. var url = "/api/Resource/QueryInvitationOfficialActivityData"
  353. var that = this
  354. this.$axios({
  355. method: 'post',
  356. url: url,
  357. headers: {
  358. Authorization: 'Bearer ' + this.token
  359. },
  360. data: {
  361. portType: 1,
  362. pageIndex: that.currentPage,
  363. pageSize: that.pageSize,
  364. Country: that.Country,
  365. UnitName: that.UnitName,
  366. Contact: that.Contact,
  367. Delegation: that.Delegation.toString(),
  368. Field: that.Field,
  369. CreateUserId: CreateUser,
  370. StartCreateTime: that.StartCreateTime,
  371. EndCreateTime: that.EndCreateTime
  372. }
  373. }).then(function (res) {
  374. console.log(res)
  375. if (res.data.code == 200) {
  376. //#endregion
  377. that.tableData = res.data.data;
  378. that.dataCount=res.data.count;
  379. } else {
  380. that.tableDatas = [];
  381. }
  382. that.loading = false
  383. }).catch(function (error) {
  384. that.loading = false
  385. that.$message.error(error);
  386. });
  387. },
  388. QueryCount() {
  389. var CreateUser = 0;
  390. if (this.CreateUserId == "" || this.CreateUserId == undefined || this.CreateUserId == null) {
  391. CreateUser = 0
  392. } else {
  393. CreateUser = this.CreateUserId
  394. }
  395. if (this.InviteTime != "" && this.InviteTime != undefined && this.InviteTime != null) {
  396. this.StartCreateTime = this.InviteTime[0]
  397. this.EndCreateTime = this.InviteTime[1]
  398. } else {
  399. this.StartCreateTime = ""
  400. this.EndCreateTime = ""
  401. }
  402. this.loading = true
  403. var url = "/api/Resource/QueryInvitationOfficialActivityData"
  404. var that = this
  405. this.$axios({
  406. method: 'post',
  407. url: url,
  408. headers: {
  409. Authorization: 'Bearer ' + this.token
  410. },
  411. data: {
  412. portType: 1,
  413. pageIndex: 0,
  414. pageSize: 0,
  415. Country: '',
  416. UnitName: '',
  417. Contact: '',
  418. Delegation: '',
  419. Field: '',
  420. CreateUserId: CreateUser,
  421. StartCreateTime: that.StartCreateTime,
  422. EndCreateTime: that.EndCreateTime
  423. }
  424. }).then(function (res) {
  425. console.log(res)
  426. if (res.data.code == 200) {
  427. that.tableData = res.data.data;
  428. that.tableDatas = that.tableData
  429. if (that.tableDatas.slice((that.currentPage - 1) * that.pageSize, that.currentPage * that.pageSize).length == 0) {
  430. if (that.currentPage > 1) {
  431. that.currentPage = that.currentPage - 1;
  432. }
  433. }
  434. if (that.CreateUserId != 0 && that.CreateUserId != "") {
  435. that.dataCount = that.tableDatas.length
  436. }
  437. } else {
  438. that.tableDatas = [];
  439. }
  440. that.loading = false
  441. }).catch(function (error) {
  442. that.loading = false
  443. that.$message.error("网络错误,请稍后重试");
  444. });
  445. },
  446. del(index, row) {
  447. this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
  448. confirmButtonText: '确定',
  449. cancelButtonText: '取消',
  450. type: 'warning'
  451. }).then(() => {
  452. var url = "/api/Resource/DelInvitationOfficialActivity"
  453. var that = this
  454. this.$axios({
  455. method: 'post',
  456. url: url,
  457. headers: {
  458. Authorization: 'Bearer ' + this.token
  459. },
  460. data: {
  461. Id: row.id,
  462. DeleteUserId: this.userId
  463. }
  464. }).then(function (res) {
  465. console.log(res)
  466. if (res.data.code == 200) {
  467. that.$message({
  468. message: '删除成功',
  469. type: 'success'
  470. });
  471. that.QueryInvitationOfficialActivityData();
  472. } else {
  473. that.$message.error('删除失败!');
  474. }
  475. that.loading = false
  476. }).catch(function (error) {
  477. that.loading = false
  478. that.$message.error("网络错误,请稍后重试");
  479. });
  480. }).catch(() => {
  481. this.$message({
  482. type: 'info',
  483. message: '操作已取消!'
  484. });
  485. });
  486. },
  487. upDate(index, row) {
  488. this.$store.state.Termsofinvitation.pgindex=this.currentPage;
  489. this.$store.state.Termsofinvitation.pageSize=this.pageSize;
  490. this.$router.push({
  491. path: "/home/OpInvitationOfficialActivityData",
  492. query: { id: row.id }
  493. })
  494. },
  495. },
  496. created(){
  497. this.estimatevuex()
  498. },
  499. mounted() {
  500. this.QueryIOAInitData();
  501. this.token = JSON.parse(localStorage.getItem('userinif')).token;
  502. this.userId = JSON.parse(localStorage.getItem('userinif')).userInfo.userId
  503. this.QueryInvitationOfficialActivityData();
  504. }
  505. }
  506. </script>
  507. <style>
  508. .communal-list {
  509. background-color: #fff;
  510. padding: 10px;
  511. box-shadow: 0 0 5px #0005;
  512. border-radius: 10px;
  513. min-height: 830px;
  514. }
  515. .communal-list .block{
  516. margin-top: 15px;
  517. }
  518. .communal-title {
  519. display: flex;
  520. font-size: 17px;
  521. font-weight: 600;
  522. color: #555;
  523. margin-top: 8px;
  524. margin-bottom: 10px;
  525. justify-content: space-between;
  526. align-items: center;
  527. }
  528. .communal-box {
  529. display: flex;
  530. }
  531. .communal-box>button {
  532. margin-left: 10px;
  533. padding: 8px 20px;
  534. }
  535. .title {
  536. width: 80px;
  537. overflow: hidden;
  538. text-overflow: ellipsis;
  539. white-space: nowrap;
  540. cursor: pointer;
  541. }
  542. </style>