index-pc.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. var selectDataIds = []
  2. var inInjectBI = getParam('report') === 'bi' // 是否bi嵌入
  3. if (inInjectBI) {
  4. $('body').addClass('in-bi')
  5. }
  6. var vm = new Vue({
  7. el: '.search-content',
  8. delimiters: ['${', '}'],
  9. components: {
  10. selectListComponent: selectListComponent,
  11. dateTimeComponent: dateTimeComponent,
  12. selectLevel2Component: selectLevel2Component,
  13. articleItemComponent: articleItemComponent,
  14. noData: noDataComponent
  15. },
  16. data: function () {
  17. return {
  18. sessKey: '$data-collection-index',
  19. inInjectBI: inInjectBI,
  20. bi: {
  21. loading: false,
  22. addedIds: []
  23. },
  24. powerInfo: {},
  25. powerLoaded: false,
  26. toast: {
  27. show: false,
  28. content: '暂无数据'
  29. },
  30. buyclassMap: buyclassArr,
  31. tagList: [],
  32. tagSelectList: [],
  33. buyerPhoneOptions: [
  34. {
  35. label: '不限',
  36. value: 0
  37. },
  38. {
  39. label: '有联系方式',
  40. value: 1
  41. },
  42. {
  43. label: '无联系方式',
  44. value: -1
  45. }
  46. ],
  47. filterState: {
  48. tags: [],
  49. selectTime: '',
  50. timeSelectorObj: {
  51. start: '',
  52. end: '',
  53. exact: ''
  54. },
  55. buyerclass: [],
  56. buyerclassObj: {}, // buyerclass原始选中数据
  57. buyerPhone: 0, // 采购单位联系方式
  58. winnerPhone: 0, // 中标企业联系方式
  59. },
  60. listState: {
  61. listType: 'line', // line/table
  62. loaded: false, // 是否已经搜索过
  63. loading: false,
  64. pageNum: 1, // 当前页
  65. pageSize: 50, // 每页多少条数据
  66. total: 0, // 一共多少条数据
  67. list: [] // 查询请求返回的数据
  68. },
  69. currentPageAllChecked: false,
  70. currentSelectItems: [],
  71. tagDrawer: {
  72. dialogShow: false,
  73. toastShow: false,
  74. show: false,
  75. currentDelTagInfo: {}, // 当前要删除标签的信息
  76. },
  77. addTagInfo: {
  78. content: ''
  79. },
  80. powerDialogShow: false,
  81. urlFilterTagId: [],
  82. tableShowData: [],
  83. tableFirst20: [],
  84. checkNum: 0,
  85. exportChecked: false
  86. }
  87. },
  88. watch: {
  89. exportChecked (newval) {
  90. $.ajax({
  91. type: 'POST',
  92. url: '/front/dataExport/setDontPromptAgain',
  93. contentType: 'application/x-www-form-urlencoded',
  94. data: {
  95. status: newval ? '1' : '0'
  96. }
  97. })
  98. }
  99. },
  100. computed: {
  101. biEnv: function () {
  102. return this.inInjectBI
  103. },
  104. power: function () {
  105. return this.powerInfo.entniche || this.powerInfo.member || this.powerInfo.vip !== 0
  106. }
  107. },
  108. created: function () {
  109. var _this = this
  110. var tag = utils.getParam('tag')
  111. if (tag) {
  112. this.urlFilterTagId = tag.split(',')
  113. }
  114. if (this.biEnv) {
  115. this.getBiAddedProjects()
  116. }
  117. this.getPower(function () {
  118. if (_this.hasRestoreState()) {
  119. // 等TagList请求完成后在恢复数据
  120. _this.getTagList(function () {
  121. setTimeout(function () {
  122. var $data = _this.restorePageState()
  123. if (!$data) {
  124. _this.getList()
  125. }
  126. }, 0)
  127. })
  128. } else {
  129. _this.getTagList(function () {
  130. _this.getList()
  131. })
  132. }
  133. })
  134. var _this = this
  135. document.addEventListener('visibilitychange', function() {
  136. if (document.visibilityState === 'visible') {
  137. _this.getBidIsJoin()
  138. }
  139. })
  140. },
  141. methods: {
  142. showToast: function (content, timer, callback) {
  143. if (this.toast.show) return
  144. content = content || '暂无数据'
  145. timer = timer || 2000
  146. this.toast.content = content
  147. this.toast.show = true
  148. setTimeout(function () {
  149. this.toast.show = false
  150. callback && callback()
  151. }.bind(this), timer)
  152. },
  153. getPower: function (callback) {
  154. $.ajax({
  155. url: '/publicapply/bidcoll/power',
  156. type: 'POST',
  157. success: function (res) {
  158. if (res.error_code === 0 && res.data) {
  159. this.powerInfo = res.data
  160. if (!this.power) {
  161. // this.listState.pageSize = 100
  162. }
  163. }
  164. }.bind(this),
  165. complete: function () {
  166. this.powerLoaded = true
  167. callback && callback()
  168. }.bind(this)
  169. })
  170. },
  171. getTagList: function (callback) {
  172. $.ajax({
  173. url: '/publicapply/bidcoll/getLabel',
  174. type: 'POST',
  175. success: function (res) {
  176. if (res.error_code === 0) {
  177. if (res.data) {
  178. this.tagList = res.data.reverse()
  179. } else {
  180. this.tagList = []
  181. }
  182. this.initSelectTagList()
  183. if (this.urlFilterTagId.length) {
  184. this.filterState.tags = this.filterState.tags.concat(this.urlFilterTagId)
  185. }
  186. callback && callback()
  187. }
  188. }.bind(this)
  189. })
  190. },
  191. getList: function () {
  192. var _this = this
  193. var data = {
  194. pagenum: this.listState.pageNum,
  195. pagesize: this.listState.pageSize,
  196. label: this.filterState.tags.join(','),
  197. selectTime: this.filterState.selectTime,
  198. buyerclass: this.filterState.buyerclass.join(','),
  199. buyerPhone: this.filterState.buyerPhone ? this.filterState.buyerPhone : 0,
  200. winnerPhone: this.filterState.winnerPhone ? this.filterState.winnerPhone : 0
  201. }
  202. this.listState.loading = true
  203. this.listState.loaded = false
  204. $.ajax({
  205. url: '/publicapply/bidcoll/list',
  206. type: 'POST',
  207. contentType: 'application/json',
  208. data: JSON.stringify(data),
  209. success: function (res) {
  210. if (res.error_code === 0 && res.data) {
  211. var list = res.data.res
  212. if (res.data.count) {
  213. _this.listState.total = res.data.count
  214. }
  215. // 给list添加额外属性
  216. if (list) {
  217. list.forEach(function (item, index) {
  218. item.selected = false
  219. selectDataIds.forEach((sum, i) => {
  220. if(item._id == sum) {
  221. item.selected = true
  222. }
  223. })
  224. if(!item.selected) {
  225. _this.currentPageAllChecked = false
  226. } else {
  227. _this.currentPageAllChecked = true
  228. }
  229. item.joinBid = undefined
  230. item.star = true
  231. item.index = _this.calcListIndex(index)
  232. try {
  233. item.visited = visitedPath.pathVisited(
  234. new VisitedPathItem(
  235. '/article/content/*.html',
  236. 'id=' + item._id
  237. )
  238. )
  239. } catch (error) {}
  240. })
  241. this.listState.list = list || []
  242. if (_this.listState.pageNum === 1 && _this.listState.pageSize >= 50) {
  243. _this.tableShowData = list || []
  244. _this.tableFirst20 = list.slice(0, 20)
  245. }
  246. // 获取参标数据
  247. _this.getBidIsJoin()
  248. }
  249. } else {
  250. this.listState.total = 0
  251. this.listState.list = []
  252. }
  253. }.bind(this),
  254. complete: function () {
  255. this.checkAddedState()
  256. this.listState.loading = false
  257. this.listState.loaded = true
  258. }.bind(this)
  259. })
  260. },
  261. bidCollectAction: function (ids, callback) {
  262. var binfo = []
  263. ids.forEach(function (item) {
  264. binfo.push({
  265. bid: item
  266. })
  267. })
  268. var data = {
  269. baction: 'R',
  270. binfo: binfo
  271. }
  272. $.ajax({
  273. url: '/publicapply/bidcoll/action',
  274. type: 'POST',
  275. contentType: 'application/json',
  276. data: JSON.stringify(data),
  277. success: function (res) {
  278. if (res.error_code === 0 && res.data) {
  279. selectDataIds = []
  280. callback && callback()
  281. }
  282. }.bind(this)
  283. })
  284. },
  285. addTagConfirmed: function () {
  286. var name = this.addTagInfo.content
  287. if (!name) return
  288. $.ajax({
  289. url: '/publicapply/bidcoll/addLabel',
  290. type: 'POST',
  291. data: {
  292. name: name
  293. },
  294. success: function (res) {
  295. if (res.error_code === 0 && res.data) {
  296. this.addTagInfo.content = ''
  297. this.tagList.unshift({
  298. count: 0,
  299. lanme: name,
  300. lid: res.data
  301. })
  302. // 数组去重
  303. this.tagList = utils.unique(this.tagList)
  304. this.initSelectTagList()
  305. // 重新请求数据
  306. this.filterState.tags = []
  307. this.doQuery()
  308. } else {
  309. // this.showToast(res.error_msg)
  310. this.showToast('标签已经存在,无需添加')
  311. }
  312. }.bind(this)
  313. })
  314. },
  315. resetListState: function () {
  316. var state = {
  317. loaded: false,
  318. loading: false,
  319. pageNum: 1, // 当前页
  320. pageSize: 50,
  321. total: 0, // 一共多少条数据
  322. list: []
  323. }
  324. Object.assign(this.listState, state)
  325. },
  326. onPageChange: function (p) {
  327. this.listState.pageNum = p
  328. var info = this.getSelectedIdArr()
  329. var ids = info.ids
  330. if(selectDataIds.length == 0) {
  331. selectDataIds = ids
  332. } else {
  333. ids.forEach((item, index) => {
  334. //避免重复添加(若存在元素时,不添加)
  335. if(!this.contains(selectDataIds, item)) {
  336. selectDataIds.push(item)
  337. }
  338. })
  339. }
  340. this.getList()
  341. },
  342. contains: function (arr, ele) {
  343. if(arr.length == 0){
  344. return;
  345. }
  346. var i = arr.length;
  347. while (i--) {
  348. if (arr[i] == ele) {
  349. return true;
  350. }
  351. }
  352. return false;
  353. },
  354. doQuery: function () {
  355. this.resetListState()
  356. this.getList()
  357. },
  358. initSelectTagList: function () {
  359. var arr = []
  360. this.tagList.forEach(function (item) {
  361. arr.push({
  362. label: item.lanme,
  363. value: item.lid,
  364. count: item.count
  365. })
  366. })
  367. this.tagSelectList = arr
  368. },
  369. tagFilterChange: function (tagList) {
  370. this.filterState.tags = tagList
  371. this.clearSelectState()
  372. this.doQuery()
  373. },
  374. dateTimeFilterChange: function (t) {
  375. this.filterState.timeSelectorObj = t
  376. var arr = []
  377. if (t.start) {
  378. arr.push(t.start / 1000)
  379. }
  380. if (t.end) {
  381. arr.push(t.end / 1000)
  382. }
  383. if (arr.length === 0) {
  384. this.filterState.selectTime = ''
  385. } else {
  386. this.filterState.selectTime = arr.join('_')
  387. }
  388. this.clearSelectState()
  389. this.doQuery()
  390. },
  391. buyerClassFilterChange: function (buyerclass) {
  392. if (this.power) {
  393. var buyerclassArr = []
  394. this.filterState.buyerclassObj = buyerclass
  395. for (var key in buyerclass) {
  396. buyerclassArr = buyerclassArr.concat(buyerclass[key])
  397. }
  398. this.filterState.buyerclass = buyerclassArr
  399. this.clearSelectState()
  400. this.doQuery()
  401. } else {
  402. this.$refs.buyerClassFilter.setState()
  403. this.filterState.buyerclass = ''
  404. this.powerDialogShow = true
  405. }
  406. },
  407. otherFilterChange: function (t) {
  408. if (this.power) {
  409. this.clearSelectState()
  410. this.doQuery()
  411. } else {
  412. this.filterState.buyerPhone = 0
  413. this.filterState.winnerPhone = 0
  414. this.powerDialogShow = true
  415. }
  416. },
  417. changeListType: function (type) {
  418. this.listState.listType = type
  419. },
  420. dataExport: function () {
  421. const _this = this
  422. //数据导出
  423. $.ajax({
  424. type: "POST",
  425. url: "/front/dataExport/getDontPromptAgain",
  426. contentType: "application/x-www-form-urlencoded",
  427. success: function (res) {
  428. if(res.error_code === 0) {
  429. // 数据导出-判断是否展示弹框
  430. if(res.isPrompt && _this.listState.total >= 20000) {
  431. $('.have-thousand-dialog').show()
  432. // 获取微信客服二维码
  433. if (window.customers && window.customers.length > 0) {
  434. const customerInfo = window.customers.filter(v => v.name === '高静')
  435. if (customerInfo) {
  436. const html = `<img src="${customerInfo[0].wxer}" alt="">`
  437. $('.custom-wx').html(html)
  438. }
  439. }
  440. } else {
  441. $('.have-thousand-dialog').hide()
  442. // _this.toDataExportEvent()
  443. }
  444. } else {
  445. $('.have-thousand-dialog').hide()
  446. // _this.toDataExportEvent()
  447. }
  448. },
  449. error: function(err) {
  450. // _this.toDataExportEvent()
  451. }
  452. })
  453. },
  454. toDataExportEvent: function () {
  455. this.onPageChange(this.listState.pageNum)
  456. var info = this.getSelectedIdArr()
  457. var ids = info.ids
  458. var data = null
  459. if (ids.length === 0 && selectDataIds.length === 0) {
  460. data = {
  461. label: this.filterState.tags.join(','),
  462. selectTime: this.filterState.selectTime,
  463. buyerclass: this.filterState.buyerclass.join(','),
  464. buyerPhone: this.filterState.buyerPhone ? this.filterState.buyerPhone : 0,
  465. winnerPhone: this.filterState.winnerPhone ? this.filterState.winnerPhone : 0
  466. }
  467. } else {
  468. data = {
  469. selectIds: selectDataIds.join(',')
  470. }
  471. }
  472. $.ajax({
  473. url: '/publicapply/dataexpoet/bycollection',
  474. type: 'POST',
  475. data: data,
  476. success: function (res) {
  477. if (res.error_code === 0) {
  478. if (res.data._id) {
  479. this.savePageState()
  480. this.listState.loaded = true
  481. location.href = '/front/dataExport/toCreateOrderPage/' + res.data._id
  482. }
  483. }
  484. }.bind(this)
  485. })
  486. },
  487. setCloseDialog () {
  488. $('.have-thousand-dialog').hide()
  489. },
  490. setCheckBox ($this, type) {
  491. $($this).hide()
  492. if (type === 'open') {
  493. $('.el-icon-check').show()
  494. } else {
  495. $('.bif-checkbox').show()
  496. }
  497. },
  498. checkNotEnoughOnePage: function (unStarCount) {
  499. // 当前数据总共多少页数据
  500. var totalPageCount = Math.ceil(this.listState.total / this.listState.pageSize)
  501. // 选中数量大于等于当前页数量
  502. var lastCount = this.listState.list.length - unStarCount
  503. // 剩余几页数据
  504. var lastPageCount = Math.ceil((this.listState.total - unStarCount) / this.listState.pageSize)
  505. // 取消了几页数据
  506. var unStarPageCount = totalPageCount - lastPageCount
  507. console.log('剩余几页数据', lastPageCount)
  508. return {
  509. notEnoughOnePage: lastCount <= 0,
  510. lastPageCount: lastPageCount,
  511. unStarPageCount: unStarPageCount
  512. }
  513. },
  514. getListAfterUnStar: function (unStarCount) {
  515. var unStarInfo = this.checkNotEnoughOnePage(unStarCount)
  516. if (unStarInfo.notEnoughOnePage) {
  517. var diff = this.listState.pageNum - unStarInfo.unStarPageCount
  518. if (diff <= 1) {
  519. this.doQuery()
  520. } else {
  521. this.onPageChange(diff)
  522. }
  523. } else {
  524. this.getList()
  525. }
  526. },
  527. // 批量取消收藏
  528. unStarSelected: function () {
  529. baiduEvent('列表页标讯收藏-星标') // 收藏按钮百度统计
  530. var _this = this
  531. var info = this.getSelectedIdArr()
  532. var ids = info.ids
  533. var selectedArr = info.arr
  534. if (ids.length === 0 && selectDataIds.length == 0) {
  535. return this.showToast('请选择收藏信息')
  536. }
  537. if(selectDataIds.length !== 0) {
  538. ids = selectDataIds
  539. }
  540. this.bidCollectAction(ids, function () {
  541. _this.showToast('已取消收藏', null)
  542. _this.getListAfterUnStar(ids.length)
  543. })
  544. },
  545. clearSelectState: function () {
  546. selectDataIds = []
  547. this.listState.list.forEach(function (item) {
  548. item.selected = selectDataIds.indexOf(item._id) !== -1
  549. })
  550. },
  551. unStarThis: function (item) {
  552. baiduEvent('列表页标讯收藏-星标') // 收藏按钮百度统计
  553. var _this = this
  554. this.bidCollectAction([item._id], function () {
  555. _this.showToast('已取消收藏', null, function () {})
  556. _this.getListAfterUnStar(1)
  557. })
  558. },
  559. getSelectedIdArr: function () {
  560. var arr = []
  561. var ids = []
  562. this.listState.list.forEach(function (item) {
  563. if (item.selected) {
  564. arr.push(item)
  565. ids.push(item._id)
  566. }
  567. })
  568. this.currentSelectItems = ids
  569. return {
  570. ids: ids,
  571. arr: arr
  572. }
  573. },
  574. toListDetail: function (item) {
  575. try {
  576. item.visited = true
  577. visitedPath.pathVisiting(
  578. new VisitedPathItem(
  579. '/article/content/*.html',
  580. 'id=' + item._id
  581. )
  582. )
  583. } catch (error) {}
  584. window.open('/article/content/' + item._id + '.html')
  585. },
  586. calcArticleItemTags: function (article) {
  587. var arr = []
  588. if (article.area) {
  589. arr.push(article.area)
  590. }
  591. if (article.buyerclass) {
  592. arr.push(article.buyerclass)
  593. }
  594. if (article.type) {
  595. arr.push(article.type)
  596. }
  597. if (article.budget) {
  598. arr.push(utils.moneyUnit(article.budget))
  599. }
  600. return arr
  601. },
  602. calcListIndex: function (index) {
  603. return (this.listState.pageSize * (this.listState.pageNum - 1)) + index + 1
  604. },
  605. calcMoney: function (m) {
  606. if (m) {
  607. return parseInt(utils.moneyUnit(m))
  608. } else {
  609. return ''
  610. }
  611. },
  612. calcArticleType: function (type) {
  613. if (type) {
  614. return type + '公告'
  615. } else {
  616. return ''
  617. }
  618. },
  619. calcTime: function (time, pattern) {
  620. if (time) {
  621. var t = new Date(time)
  622. return t.pattern(pattern)
  623. } else {
  624. return ''
  625. }
  626. },
  627. allCheckboxChange: function (state) {
  628. let _this = this
  629. this.listState.list.forEach(function (item) {
  630. if(state) {
  631. if(!_this.contains(selectDataIds,item._id)) {
  632. selectDataIds.push(item._id)
  633. }
  634. } else {
  635. selectDataIds.forEach(function(v,index) {
  636. if (v == item._id) {
  637. selectDataIds.splice(index, 1)
  638. }
  639. })
  640. }
  641. item.selected = state
  642. })
  643. this.checkNum = selectDataIds? selectDataIds.length : 0
  644. },
  645. listItemCheckboxChange: function (data, check) {
  646. if (check) {
  647. if(!this.contains(selectDataIds, data)) {
  648. selectDataIds.push(data)
  649. }
  650. } else {
  651. selectDataIds.forEach(function(v,index) {
  652. if (v == data) {
  653. selectDataIds.splice(index, 1)
  654. }
  655. })
  656. }
  657. var arr = []
  658. this.listState.list.forEach(function (item) {
  659. arr.push(item.selected)
  660. })
  661. this.currentPageAllChecked = arr.indexOf(false) === -1
  662. this.checkNum = selectDataIds? selectDataIds.length : 0
  663. },
  664. openTagDrawer: function () {
  665. this.tagDrawer.show = true
  666. },
  667. openVipPage: function () {
  668. window.open('/front/subscribe.html')
  669. },
  670. drawerConfirm: function () {
  671. this.tagDrawer.show = false
  672. },
  673. drawerCancel: function () {
  674. this.tagDrawer.show = false
  675. },
  676. delThisTag: function (tag) {
  677. this.tagDrawer.dialogShow = true
  678. for (var key in tag) {
  679. this.$set(this.tagDrawer.currentDelTagInfo, key, tag[key])
  680. }
  681. },
  682. delThisTagConfirm: function () {
  683. var _this = this
  684. var data = {
  685. lids: this.tagDrawer.currentDelTagInfo.value,
  686. lname: this.tagDrawer.currentDelTagInfo.label,
  687. laction: 'D'
  688. }
  689. $.ajax({
  690. url: '/publicapply/bidcoll/label',
  691. type: 'POST',
  692. contentType: 'application/json',
  693. data: JSON.stringify(data),
  694. success: function (res) {
  695. if (res.error_code === 0) {
  696. _this.tagDrawer.dialogShow = false
  697. if (res.data) {
  698. _this.tagDrawer.toastShow = true
  699. setTimeout(function () {
  700. _this.tagDrawer.toastShow = false
  701. _this.getTagList()
  702. // 重新请求数据
  703. _this.filterState.tags = []
  704. _this.doQuery()
  705. }, 1500)
  706. }
  707. }
  708. }.bind(this)
  709. })
  710. },
  711. savePageState: function () {
  712. var data = {
  713. filterState: this.filterState,
  714. listState: this.listState,
  715. currentSelectItems: this.currentSelectItems,
  716. currentPageAllChecked: this.currentPageAllChecked,
  717. selectDataIds: selectDataIds,
  718. tableShowData: this.tableShowData,
  719. tableFirst20: this.tableFirst20
  720. }
  721. this.listState.loaded = true
  722. sessionStorage.setItem(this.sessKey, JSON.stringify(data))
  723. },
  724. hasRestoreState: function () {
  725. return !!sessionStorage.getItem(this.sessKey)
  726. },
  727. restorePageState: function () {
  728. var $data = sessionStorage.getItem(this.sessKey)
  729. if ($data) {
  730. $data = JSON.parse($data)
  731. // 恢复数据
  732. Object.assign(this.filterState, $data.filterState || {})
  733. Object.assign(this.listState, $data.listState || {})
  734. Object.assign(this.currentSelectItems, $data.currentSelectItems || {})
  735. Object.assign(this.tableShowData, $data.tableShowData || [])
  736. Object.assign(this.tableFirst20, $data.tableFirst20 || [])
  737. selectDataIds = $data.selectDataIds
  738. this.listState.loading = false
  739. // 恢复页面状态
  740. this.currentPageAllChecked = $data.currentPageAllChecked
  741. sessionStorage.removeItem(this.sessKey)
  742. }
  743. return !!$data
  744. },
  745. onSizeChange: function (val) {
  746. this.listState.pageSize = val
  747. this.listState.pageNum = 1
  748. this.onPageChange(this.listState.pageNum)
  749. },
  750. getBiAddedProjects: function () {
  751. $.ajax({
  752. url: '/jyapi/biService/getInfoId',
  753. type: 'POST',
  754. success: function (res) {
  755. if (res && res.error_code === 0 && $.isArray(res.data)) {
  756. this.bi.addedIds = res.data
  757. this.checkAddedState()
  758. }
  759. }.bind(this)
  760. })
  761. },
  762. checkAddedState: function () {
  763. var _this = this
  764. var addedIds = this.bi.addedIds || []
  765. if (!$.isArray(addedIds)) return
  766. if (addedIds.length === 0) return
  767. this.listState.list.forEach(function (item) {
  768. var added = addedIds.indexOf(item._id) !== -1
  769. _this.$set(item, 'added', added)
  770. })
  771. },
  772. // 单个添加
  773. biAddProject: function (item) {
  774. if (item.added) return
  775. const id = item._id
  776. if (!id) return
  777. this.biBatchAddRequest([id])
  778. },
  779. // bi下批量操作
  780. biBatchAddSelected: function () {
  781. var ids = selectDataIds
  782. if (!$.isArray(ids)) return
  783. if (ids.length === 0) {
  784. return this.showToast('请选择要添加的信息')
  785. }
  786. this.biBatchAddRequest(ids)
  787. },
  788. biBatchAddRequest: function (ids) {
  789. if (this.bi.loading) return
  790. this.bi.loading = true
  791. var _this = this
  792. var data = {
  793. info_id: ids.join(','),
  794. source: 1
  795. }
  796. $.ajax({
  797. url: '/jyapi/biService/addProject',
  798. type: 'POST',
  799. contentType: 'application/json',
  800. data: JSON.stringify(data),
  801. success: function (res) {
  802. if (res) {
  803. if (res.error_code === 0) {
  804. if (res.data && res.data.status === 1) {
  805. _this.clearSelectState()
  806. _this.showToast('添加成功')
  807. }
  808. _this.getBiAddedProjects()
  809. } else {
  810. if (res.error_msg) {
  811. _this.showToast(res.error_msg)
  812. }
  813. }
  814. }
  815. },
  816. complete: function () {
  817. _this.bi.loading = false
  818. }
  819. })
  820. },
  821. // 获取参标数据
  822. getBidIsJoin: function () {
  823. var _this = this
  824. var paramsData = {
  825. ids: _this.listState.list.map(function(item){
  826. return item._id
  827. }).join()
  828. }
  829. $.ajax({
  830. type: 'post',
  831. contentType: "application/json",
  832. url: '/jyapi/jybx/core/participate/show?t=' + Date.now(),
  833. data: JSON.stringify(paramsData),
  834. dataType: 'json',
  835. success: function (r) {
  836. if (r.data && r.error_code == 0) {
  837. var data = r.data || []
  838. if(data.length > 0) {
  839. Bidrenewal_Dialog.initBidrenewalDialog = true // 加载参标状态更新弹窗
  840. }
  841. data.forEach(function(item) {
  842. _this.listState.list.forEach(function(temp) {
  843. if (item.id == temp._id) {
  844. temp.joinBid = Boolean(item.value)
  845. }
  846. })
  847. })
  848. }
  849. }
  850. })
  851. },
  852. /******参标********/
  853. /**
  854. * 参标、终止参标
  855. * @param action in:参标;out:终止参标;transfer:划转
  856. * @param bidIds 招标信息id(加密) 必传
  857. * @param projectIds 项目信息id ,多个,号隔开 划转和终止参标必传(bidIds和projectIds必传一个)
  858. * @param callback
  859. */
  860. joinBidAction: function (item) {
  861. if(item.joinBid) {
  862. return this.showToast('如需终止参标,需要在详情页进行操作。')
  863. }
  864. var params = {
  865. bidIds: item._id
  866. }
  867. var _this = this
  868. $.ajax({
  869. type:'post',
  870. contentType: "application/json",
  871. url:'/jyapi/jybx/core/participate/in/info',
  872. data: JSON.stringify(params),
  873. dataType: 'json',
  874. success: function(r){
  875. if (r && r.data && r.error_code == 0) {
  876. item.joinBid = true
  877. // _this.showToast('已参标,请前往我的参标项目列表查看。')
  878. try{
  879. Bidrenewal_Dialog.sendId(item._id)
  880. window.$BidrenewalDialog.open()
  881. }catch(e){
  882. setTimeout(function() {
  883. Bidrenewal_Dialog.sendId(item._id)
  884. window.$BidrenewalDialog.open()
  885. } , 100)
  886. }
  887. } else if(r.error_code == -1) {
  888. var msg = r.error_msg || '参标错误,请稍后重试'
  889. _this.showToast(msg)
  890. }
  891. }
  892. })
  893. },
  894. goCollect: function () {
  895. window.open('/page_workDesktop/work-bench/page?link=' + encodeURIComponent(location.origin + '/jylab/supsearch/index.html'))
  896. }
  897. }
  898. })