index-pc.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. var vm = new Vue({
  2. el: '.search-content',
  3. delimiters: ['${', '}'],
  4. components: {
  5. selectListComponent: selectListComponent,
  6. dateTimeComponent: dateTimeComponent,
  7. selectLevel2Component: selectLevel2Component,
  8. articleItemComponent: articleItemComponent,
  9. noData: noDataComponent
  10. },
  11. data: function () {
  12. return {
  13. powerInfo: {},
  14. power: false,
  15. powerLoaded: false,
  16. toast: {
  17. show: false,
  18. content: '暂无数据'
  19. },
  20. buyclassMap: buyclassArr,
  21. tagList: [],
  22. tagSelectList: [],
  23. buyerPhoneOptions: [
  24. {
  25. label: '不限',
  26. value: 0
  27. },
  28. {
  29. label: '有联系方式',
  30. value: 1
  31. },
  32. {
  33. label: '无联系方式',
  34. value: -1
  35. }
  36. ],
  37. filterState: {
  38. tags: [],
  39. timeStart: 0,
  40. timeEnd: 0,
  41. buyerclass: [],
  42. buyerPhone: 0, // 采购单位联系方式
  43. bidPhone: 0, // 中标企业联系方式
  44. },
  45. listState: {
  46. listType: 'line', // line/table
  47. loaded: false, // 是否已经搜索过
  48. loading: false,
  49. pageNum: 1, // 当前页
  50. pageSize: 50, // 每页多少条数据
  51. total: 0, // 一共多少条数据
  52. list: [] // 查询请求返回的数据
  53. },
  54. currentPageAllChecked: false,
  55. tagDrawer: {
  56. dialogShow: false,
  57. toastShow: false,
  58. show: false,
  59. currentDelTagInfo: {}, // 当前要删除标签的信息
  60. }
  61. }
  62. },
  63. created: function () {
  64. this.getPower(function () {
  65. this.getTagList()
  66. this.getList()
  67. }.bind(this))
  68. },
  69. mounted: function () {},
  70. methods: {
  71. showToast: function (content, timer, callback) {
  72. content = content || '暂无数据'
  73. timer = timer || 2000
  74. this.toast.content = content
  75. this.toast.show = true
  76. setTimeout(function () {
  77. this.toast.show = false
  78. callback && callback()
  79. }.bind(this), timer)
  80. },
  81. getPower: function (callback) {
  82. $.ajax({
  83. url: '/publicapply/bidcoll/power',
  84. type: 'POST',
  85. success: function (res) {
  86. if (res.error_code === 0 && res.data) {
  87. this.powerInfo = res.data
  88. this.checkPower()
  89. }
  90. }.bind(this),
  91. complete: function () {
  92. this.powerLoaded = true
  93. callback && callback()
  94. }.bind(this)
  95. })
  96. },
  97. checkPower: function () {
  98. this.power = this.powerInfo.entniche || this.powerInfo.member || this.powerInfo.vip !== 0
  99. if (!this.power) {
  100. this.listState.pageSize = 100
  101. }
  102. },
  103. getTagList: function () {
  104. $.ajax({
  105. url: '/publicapply/bidcoll/getLabel',
  106. type: 'POST',
  107. success: function (res) {
  108. if (res.error_code === 0 && res.data) {
  109. this.tagList = res.data
  110. this.initSelectTagList()
  111. }
  112. }.bind(this)
  113. })
  114. },
  115. getList: function () {
  116. var _this = this
  117. var data = {
  118. pagenum: this.listState.pageNum,
  119. pagesize: this.listState.pageSize,
  120. label: this.filterState.tags.join(','),
  121. selectTime: this.filterState.timeStart / 1000 + '_' + this.filterState.timeEnd / 1000,
  122. buyerclass: this.filterState.buyerclass.join(','),
  123. buyPhone: this.filterState.buyPhone ? this.filterState.buyPhone : 0,
  124. bidPhone: this.filterState.bidPhone ? this.filterState.bidPhone : 0
  125. }
  126. this.listState.loading = true
  127. this.listState.loaded = false
  128. $.ajax({
  129. url: '/publicapply/bidcoll/list',
  130. type: 'POST',
  131. contentType: 'application/json',
  132. data: JSON.stringify(data),
  133. success: function (res) {
  134. if (res.error_code === 0 && res.data) {
  135. var list = res.data.res
  136. if (res.data.count) {
  137. this.listState.total = res.data.count
  138. }
  139. // 给list添加额外属性
  140. if (list) {
  141. list.forEach(function (item, index) {
  142. item.selected = false
  143. item.star = true
  144. item.index = _this.calcListIndex(index)
  145. })
  146. this.listState.list = list || []
  147. }
  148. } else {
  149. this.listState.total = 0
  150. this.listState.list = []
  151. }
  152. }.bind(this),
  153. complete: function () {
  154. this.listState.loading = false
  155. this.listState.loaded = true
  156. }.bind(this)
  157. })
  158. },
  159. bidCollectAction: function (ids, callback) {
  160. var binfo = []
  161. ids.forEach(function (item) {
  162. binfo.push({
  163. bid: item
  164. })
  165. })
  166. var data = {
  167. baction: 'R',
  168. binfo: binfo
  169. }
  170. $.ajax({
  171. url: '/publicapply/bidcoll/action',
  172. type: 'POST',
  173. contentType: 'application/json',
  174. data: JSON.stringify(data),
  175. success: function (res) {
  176. if (res.error_code === 0 && res.data) {
  177. callback && callback()
  178. }
  179. }.bind(this)
  180. })
  181. },
  182. resetListState: function () {
  183. var state = {
  184. loaded: false,
  185. loading: false,
  186. pageNum: 1, // 当前页
  187. total: 0, // 一共多少条数据
  188. list: []
  189. }
  190. Object.assign(this.listState, state)
  191. },
  192. onPageChange: function (p) {
  193. this.listState.pageNum = p
  194. this.getList()
  195. },
  196. doQuery: function () {
  197. this.resetListState()
  198. this.getList()
  199. },
  200. initSelectTagList: function () {
  201. var arr = []
  202. this.tagList.forEach(function (item) {
  203. arr.push({
  204. label: item.lanme,
  205. value: item.lid,
  206. count: item.count
  207. })
  208. })
  209. this.tagSelectList = arr
  210. },
  211. tagFilterChange: function (tagList) {
  212. this.filterState.tags = tagList
  213. this.doQuery()
  214. },
  215. dateTimeFilterChange: function (t) {
  216. this.filterState.timeStart = t.start
  217. this.filterState.timeEnd = t.end
  218. this.doQuery()
  219. },
  220. buyerClassFilterChange: function (buyerclass) {
  221. var buyerclassArr = []
  222. for (var key in buyerclass) {
  223. buyerclassArr = buyerclassArr.concat(buyerclass[key])
  224. }
  225. this.filterState.buyerclass = buyerclassArr
  226. this.doQuery()
  227. },
  228. otherFilterChange: function (t) {
  229. this.doQuery()
  230. },
  231. changeListType: function (type) {
  232. this.listState.listType = type
  233. },
  234. dataExport: function () {
  235. var info = this.getSelectedIdArr()
  236. var ids = info.ids
  237. if (ids.length !== 0) {
  238. return window.open('/front/dataExport/superSearchExport?selectIds=' + ids.join(','))
  239. }
  240. },
  241. // 批量取消收藏
  242. unStarSelected: function () {
  243. var _this = this
  244. var info = this.getSelectedIdArr()
  245. var ids = info.ids
  246. var selectedArr = info.arr
  247. if (ids.length === 0) {
  248. return this.showToast('请选择收藏信息')
  249. }
  250. this.bidCollectAction(ids, function () {
  251. selectedArr.forEach(function (item) {
  252. item.star = false
  253. })
  254. _this.showToast('已取消收藏', null, function () {
  255. _this.getList()
  256. })
  257. })
  258. },
  259. unStarThis: function (item) {
  260. var _this = this
  261. this.bidCollectAction([item._id], function () {
  262. _this.showToast('已取消收藏', null, function () {
  263. item.star = false
  264. _this.getList()
  265. })
  266. })
  267. },
  268. getSelectedIdArr: function () {
  269. var arr = []
  270. var ids = []
  271. this.listState.list.forEach(function (item) {
  272. if (item.selected) {
  273. arr.push(item)
  274. ids.push(item._id)
  275. }
  276. })
  277. return {
  278. ids: ids,
  279. arr: arr
  280. }
  281. },
  282. toListDetail: function (item) {
  283. window.open('/article/content/' + item._id + '.html')
  284. },
  285. calcArticleItemTags: function (article) {
  286. var arr = []
  287. if (article.area) {
  288. arr.push(article.area)
  289. }
  290. if (article.buyerclass) {
  291. arr.push(article.buyerclass)
  292. }
  293. if (article.type) {
  294. arr.push(article.type)
  295. }
  296. if (article.budget) {
  297. arr.push(utils.moneyUnit(article.budget))
  298. }
  299. return arr
  300. },
  301. calcListIndex: function (index) {
  302. return (this.listState.pageSize * (this.listState.pageNum - 1)) + index + 1
  303. },
  304. calcMoney: function (m) {
  305. if (m) {
  306. return parseInt(utils.moneyUnit(m))
  307. } else {
  308. return ''
  309. }
  310. },
  311. calcArticleType: function (type) {
  312. if (type) {
  313. return type + '公告'
  314. } else {
  315. return ''
  316. }
  317. },
  318. calcTime: function (time, pattern) {
  319. if (time) {
  320. var t = new Date(time)
  321. return t.pattern(pattern)
  322. } else {
  323. return ''
  324. }
  325. },
  326. allCheckboxChange: function (state) {
  327. this.listState.list.forEach(function (item) {
  328. item.selected = state
  329. })
  330. },
  331. listItemCheckboxChange: function () {
  332. var arr = []
  333. this.listState.list.forEach(function (item) {
  334. arr.push(item.selected)
  335. })
  336. this.currentPageAllChecked = arr.indexOf(false) === -1
  337. },
  338. openTagDrawer: function () {
  339. this.tagDrawer.show = true
  340. },
  341. drawerConfirm: function () {
  342. this.tagDrawer.show = false
  343. },
  344. drawerCancel: function () {
  345. this.tagDrawer.show = false
  346. },
  347. delThisTag: function (tag) {
  348. this.tagDrawer.dialogShow = true
  349. this.tagDrawer.currentDelTagInfo = tag
  350. },
  351. delThisTagConfirm: function () {
  352. var _this = this
  353. var data = {
  354. lids: this.tagDrawer.currentDelTagInfo.value,
  355. lname: this.tagDrawer.currentDelTagInfo.label,
  356. laction: 'D'
  357. }
  358. $.ajax({
  359. url: '/publicapply/bidcoll/label',
  360. type: 'POST',
  361. contentType: 'application/json',
  362. data: JSON.stringify(data),
  363. success: function (res) {
  364. if (res.error_code === 0) {
  365. _this.tagDrawer.dialogShow = false
  366. if (res.data) {
  367. _this.tagDrawer.toastShow = true
  368. setTimeout(function () {
  369. _this.tagDrawer.toastShow = false
  370. _this.getTagList()
  371. }, 1500)
  372. }
  373. }
  374. }.bind(this)
  375. })
  376. },
  377. }
  378. })