clue.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. import pullUpRefresh from "@/utils/pullUpRefresh";
  2. import dayjs from "dayjs";
  3. export default {
  4. mixins: [pullUpRefresh],
  5. provide() {
  6. return {
  7. refreshData: {
  8. resetData: this.resetData
  9. }
  10. }
  11. },
  12. computed: {
  13. currentIndex() {
  14. return this.queryParams.type == 1 ? 0 : 1;
  15. }
  16. },
  17. onPullDownRefresh() {
  18. uni.stopPullDownRefresh();
  19. // 刷新
  20. },
  21. data() {
  22. return {
  23. clueStateList: [],
  24. mapHeight: "0px",
  25. key: new Date().getTime(),
  26. clueTagGroupVoList: [],
  27. dicts: {
  28. caseStatusDicts: [],
  29. crmFollowStatus: [],
  30. crmCallStatus: [],
  31. clueEntranceType: [],
  32. crmClueBiz: [],
  33. crmClueObj: [],
  34. crmClueType: []
  35. },
  36. options: [{
  37. value: "3",
  38. label: "电话/微信"
  39. },
  40. {
  41. value: "1",
  42. label: "姓名"
  43. },
  44. {
  45. value: "8",
  46. label: "广告主ID"
  47. },
  48. {
  49. value: "7",
  50. label: "广告主名称"
  51. },
  52. {
  53. value: "10",
  54. label: "广告ID"
  55. },
  56. {
  57. value: "9",
  58. label: "广告名称"
  59. },
  60. {
  61. value: "11",
  62. label: "标题ID"
  63. },
  64. {
  65. value: "12",
  66. label: "视频ID"
  67. },
  68. {
  69. value: "5",
  70. label: "qq号"
  71. },
  72. {
  73. value: "6",
  74. label: "邮箱"
  75. },
  76. {
  77. value: "2",
  78. label: "线索ID"
  79. },
  80. ],
  81. queryParams: {
  82. name: undefined,
  83. telephone: undefined,
  84. weixin: undefined,
  85. createTimeStart: dayjs().format("YYYY-MM-DD"),
  86. createTimeEnd: dayjs().format("YYYY-MM-DD"),
  87. conditionContent: undefined,
  88. condition: "3",
  89. batchCodes: [],
  90. clueIds: [],
  91. deptName: undefined,
  92. deptIds: [],
  93. type: "1",
  94. pageNum: 1,
  95. pageSize: 20,
  96. allTagList: [],
  97. clueStateList: [],
  98. followStatusList: [],
  99. handleStateList: [],
  100. convertStatusList: [],
  101. followCountStart: undefined,
  102. followCountEnd: undefined,
  103. autoProvince: undefined,
  104. autoCity: undefined,
  105. autoArea: undefined,
  106. manualProvince: undefined,
  107. manualCity: undefined,
  108. manualArea: undefined,
  109. clueEntranceType: [],
  110. clueBizType: undefined,
  111. clueObjType: undefined,
  112. clueAdType: undefined,
  113. clueOperationId: undefined,
  114. clueOwnerId: undefined,
  115. sort: undefined,
  116. clueState: undefined,
  117. sortField: undefined,
  118. appNames: [],
  119. appNameLabel: undefined,
  120. isRepetitionOperWeixinName: '',
  121. isRepetitionOperationName: '',
  122. isVideoIdIsNull: '',
  123. advName: "",
  124. promotionName: "",
  125. advId: "",
  126. promotionId: "",
  127. titleId: "",
  128. videoId: "",
  129. },
  130. trendModal: false,
  131. chartData:{},
  132. color:[],
  133. opts: {
  134. color: this.color,
  135. padding: [20, 10, 20, 0],
  136. dataLabel: true,
  137. dataPointShape: true,
  138. enableScroll: true,
  139. xAxis: {
  140. disableGrid: true,
  141. scrollShow: true,
  142. itemCount: 10,
  143. rotateLabel: true,
  144. rotateAngle: 45,
  145. },
  146. yAxis: {
  147. gridType: "dash",
  148. dashLength: 7,
  149. },
  150. legend: {
  151. show: false,
  152. type: 'scroll',
  153. orient: 'horizontal',
  154. pageSize: 3,
  155. pageIconSize: 12,
  156. pageIconColor: '#666',
  157. pageIconInactiveColor: '#ccc',
  158. pageTextStyle: {
  159. color: '#666',
  160. fontSize: 12
  161. },
  162. bottom: 0
  163. },
  164. extra: {
  165. line: {
  166. type: "curve",
  167. width: 3,
  168. activeType: "hollow",
  169. linearType: "custom",
  170. onShadow: true,
  171. animation: "horizontal"
  172. },
  173. tooltip:{
  174. legendShow: true,
  175. bgOpacity: 0.6,
  176. }
  177. }
  178. },
  179. model: "",
  180. maxPrice: [],
  181. minPrice: [],
  182. chartShow: false,
  183. tableData: [],
  184. date:'',
  185. columns: [
  186. { label: '型号', prop: 'model'},
  187. { label: '价格(元)', prop: 'price' },
  188. ],
  189. }
  190. },
  191. onPullDownRefresh() {
  192. uni.stopPullDownRefresh();
  193. this.resetData();
  194. },
  195. mounted() {
  196. uni.getSystemInfo({
  197. success: (e) => {
  198. const {
  199. windowTop,
  200. windowBottom,
  201. windowHeight
  202. } = e;
  203. this.mapHeight = (windowHeight - 70) + 'px';
  204. }
  205. });
  206. this.getDicts();
  207. // this.handleLoadData();
  208. this.resetData();
  209. },
  210. // onShow() {
  211. // this.resetData();
  212. // },
  213. methods: {
  214. handleTrend() {
  215. this.trendModal = true;
  216. },
  217. handleTrendConfirm() {
  218. this.model = ""
  219. this.date = ""
  220. this.tableData = []
  221. this.chartShow = false
  222. this.trendModal = false;
  223. },
  224. searchTrend(val) {
  225. if (val !== ''){
  226. uni.$u.api.inquiryChart({
  227. model: val,
  228. }).then(res => {
  229. if(res.data.length == 0){
  230. uni.$u.toast("暂无数据")
  231. this.minPrice = []
  232. this.maxPrice = []
  233. this.chartShow = false
  234. return
  235. }
  236. const response = res.data
  237. this.maxPrice = []
  238. this.minPrice = []
  239. this.color = []
  240. const categories = []
  241. const dateMap = {}
  242. response.forEach(item => {
  243. this.maxPrice.push(item.max)
  244. this.minPrice.push(item.min)
  245. item.list.forEach(i => {
  246. if (!dateMap[i.recycleTime]) {
  247. dateMap[i.recycleTime] = true
  248. categories.push(i.recycleTime)
  249. }
  250. })
  251. })
  252. const series = response.map((item) => {
  253. const color = this.getRandomColor()
  254. this.color.push(color)
  255. const data = categories.map(date => {
  256. const itemData = item.list.find(i => i.recycleTime === date)
  257. return itemData ? itemData.price : null
  258. })
  259. return {
  260. name: item.model,
  261. data: data,
  262. setShadow: [
  263. 3,
  264. 8,
  265. 15,
  266. color
  267. ],
  268. }
  269. })
  270. this.opts.color = this.color
  271. const chartData = {
  272. categories: categories,
  273. series: series
  274. }
  275. this.chartData = JSON.parse(JSON.stringify(chartData))
  276. this.chartShow = true
  277. }).catch((err) => {
  278. uni.$u.toast(err)
  279. })
  280. }
  281. },
  282. handleChartClick(event) {
  283. console.log(event);
  284. const index = event.currentIndex.index;
  285. // 获取点击的日期
  286. const date = this.chartData.categories[index];
  287. this.date = date;
  288. // 构建该日期的所有型号价格数据
  289. const tableData = [];
  290. this.chartData.series.forEach(series => {
  291. const price = series.data[index];
  292. if (price !== null) {
  293. tableData.push({
  294. model: series.name,
  295. price: price
  296. });
  297. }
  298. });
  299. this.tableData = tableData;
  300. },
  301. getRandomColor(){
  302. var letters = '0123456789ABCDEF';
  303. var color = '#';
  304. for (var i = 0; i < 6; i++) {
  305. color += letters[Math.floor(Math.random() * 16)];
  306. }
  307. return color;
  308. },
  309. handleAddClue() {
  310. uni.navigateTo({
  311. url: "/pages/addClue/index"
  312. })
  313. },
  314. handleClueStateClick(item) {
  315. this.queryParams.clueState = item.clueState;
  316. this.resetData();
  317. },
  318. handleKeyword() {
  319. this.resetData();
  320. },
  321. handleKeywordClear() {
  322. // 组件有bug 清空后的值还是存在
  323. this.queryParams.conditionContent = "";
  324. this.resetData();
  325. },
  326. handleShowTag() {
  327. this.$refs.clueTag.showModal();
  328. },
  329. async handleClueTagConfirm() {
  330. this.resetData();
  331. },
  332. async getDicts() {
  333. this.$getDicts('crm_clue_phase').then(res => {
  334. this.dicts.caseStatusDicts = res;
  335. });
  336. this.$getDicts('crm_follow_status').then(res => {
  337. this.dicts.crmFollowStatus = res;
  338. })
  339. this.$getDicts('crm_call_status').then(res => {
  340. this.dicts.crmCallStatus = res;
  341. })
  342. this.$getDicts('clue_entrance_type').then(res => {
  343. this.dicts.clueEntranceType = res;
  344. });
  345. this.$getDicts('crm_clue_biz').then(res => {
  346. this.dicts.crmClueBiz = res;
  347. });
  348. this.$getDicts('crm_clue_obj').then(res => {
  349. this.dicts.crmClueObj = res;
  350. });
  351. this.$getDicts('crm_clue_type').then(res => {
  352. this.dicts.crmClueType = res;
  353. });
  354. uni.$u.api.getClueTagGroupVoList({ tagGroupApplication: '1' }).then(({
  355. data
  356. }) => {
  357. this.clueTagGroupVoList = data;
  358. });
  359. },
  360. getOtherData() {
  361. this.statisticsCaseState();
  362. },
  363. async statisticsCaseState() {
  364. const {
  365. data
  366. } = await uni.$u.api.statisticsCaseState(this.queryParams);
  367. this.clueStateList = data;
  368. },
  369. handleshowFilter() {
  370. this.$refs.filter.show();
  371. },
  372. handleShowSort() {
  373. this.$refs.sort.show();
  374. },
  375. sectionChange(val) {
  376. this.queryParams.type = val == 0 ? 1 : 2;
  377. this.resetData();
  378. },
  379. handleConfirm() {
  380. this.resetData();
  381. },
  382. handleConditionChange() {
  383. if (this.queryParams.conditionContent) {
  384. this.resetData();
  385. }
  386. },
  387. handleToDetail(item) {
  388. const {
  389. id,
  390. name
  391. } = item;
  392. uni.navigateTo({
  393. url: `/pages/clueDetail/index?clueId=${id}&name=${name}&type=${this.queryParams.type}`,
  394. });
  395. },
  396. inquirySuccess() {
  397. console.log('inquirySuccess');
  398. this.resetData();
  399. },
  400. async getList() {
  401. const {
  402. pageNum,
  403. pageSize,
  404. ...params
  405. } = this.queryParams;
  406. const {
  407. rows,
  408. total
  409. } = await uni.$u.api.getClueMainInfoList({
  410. pageSize,
  411. pageNum
  412. }, params);
  413. rows.forEach(v => {
  414. if (v.repetitionOperationName) {
  415. // 按逗号分割成数组
  416. const parts = v.repetitionOperationName.split(',');
  417. // 对每个部分提取 '-' 前面的内容
  418. const result = parts.map(part => part.split('-')[0]).join(',');
  419. v.repetitionOperationName = result;
  420. }
  421. if (v.repetitionOperWeixinName) {
  422. // 按逗号分割成数组
  423. const parts = v.repetitionOperWeixinName.split(',');
  424. // 对每个部分提取 '-' 前面的内容
  425. const result = parts.map(part => part.split('-')[0]).join(',');
  426. v.repetitionOperWeixinName = result;
  427. }
  428. })
  429. return rows;
  430. }
  431. }
  432. }