testData.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. import HeaderData from "../../components/HeaderData";
  2. import HistogramHorizontal from "../../components/HistogramHorizontal";
  3. import HistogramHorizontals from "../../components/HistogramHorizontals";
  4. import api from '../../api/test'
  5. import editorApi from '../../api/editor'
  6. import timeFormat from '../../util/time'
  7. import { format } from "util";
  8. export default {
  9. components: {
  10. HeaderData, HistogramHorizontal, HistogramHorizontals
  11. },
  12. data() {
  13. return {
  14. isCopy: false,
  15. houseList: [],
  16. ownHouseName: "所属项目",
  17. dataList: [],
  18. isFilter: false,
  19. isShowTable: true,
  20. checkList: [[]],
  21. data: [],
  22. value: [],
  23. oldValue: [],
  24. options: [],
  25. questionList: [],
  26. questionListSel: [],
  27. filterList: [""],
  28. questionChilds: [],
  29. answerData: [],
  30. currentDate: null,
  31. filterStr: "",
  32. chartData: [],
  33. isCrossAnalyse: false,
  34. condition: [],
  35. analyseCommandSel: "全部",
  36. analyseOptions: [],
  37. analyseValue: [],
  38. crossAnalyse: [],
  39. optionsX: [],
  40. optionsXValue: [],
  41. optionsXOldValue: [],
  42. optionsY: [],
  43. optionsYValue: [],
  44. optionsYOldValue: [],
  45. filterXList: [""],
  46. filterYList: [""],
  47. selectedDataList: [],
  48. }
  49. },
  50. watch: {
  51. answerData: function (val) {
  52. var questionList = val.questionList;
  53. this.chartData = []
  54. for (var i = 0; i < questionList.length; i++) {
  55. var question = questionList[i];
  56. var data = []
  57. var optionList = question.optionList;
  58. for (var j = 0; j < optionList.length; j++) {
  59. var sold = question.answerTotal == 0 ? 0 : ((optionList[j].answerCount / question.answerTotal) * 100).toFixed(0)
  60. data.push({ genre: optionList[j].content, sold: parseInt(sold) })
  61. }
  62. var conditionQuestion = { data: data, ...question }
  63. this.chartData.push(conditionQuestion);
  64. }
  65. },
  66. analyseCommandSel: function (val) {
  67. this.analyseOptions = [];
  68. this.analyseValue = [];
  69. if (val == "全部") {
  70. } else if (val == "数据包") {
  71. var bagList = this.condition.bagList;
  72. for (var i = 0; i < bagList.length; i++) {
  73. this.analyseOptions.push({ value: bagList[i].analyseBagId, label: bagList[i].title, disabled: false })
  74. }
  75. } else {
  76. var locationList = this.condition.locationList;
  77. let locationTemp = []
  78. for (var i = 0; i < locationList.length; i++) {
  79. var item = locationList[i]
  80. if (item.city == "") {
  81. item.city = item.province;
  82. }
  83. locationTemp.push(item)
  84. }
  85. locationList = locationTemp;
  86. let result = Object.values(locationList.reduce((m, n) => {
  87. if (!m[n.province]) {
  88. m[n.province] = { value: n.province, children: [] }
  89. }
  90. m[n.province].children.push(n)
  91. return m
  92. }, {}))
  93. console.log("XXXX:result:", result)
  94. var arr = []
  95. for (var i = 0; i < result.length; i++) {
  96. var list = result[i].children;
  97. let results = Object.values(list.reduce((m, n) => {
  98. if (!m[n.city]) {
  99. m[n.city] = { value: n.city, label: n.city, children: [] }
  100. }
  101. m[n.city].children.push({ value: n.district, label: n.district })
  102. return m
  103. }, {}))
  104. arr.push({ value: result[i].value, label: result[i].value, children: results })
  105. }
  106. this.analyseOptions = arr;
  107. }
  108. },
  109. options: function (val) {
  110. if (val) {
  111. this.getCondition();
  112. }
  113. }
  114. },
  115. created() {
  116. this.houseList = [];
  117. editorApi.houseList().then((res) => {
  118. if (res.success) {
  119. this.houseList = res.list;
  120. }
  121. });
  122. this.getTestList();
  123. },
  124. methods: {
  125. async changeTest(item) {
  126. console.log("XXXXXX1", item);
  127. var list = []
  128. for (var i = 0; i < this.dataList.length; i++) {
  129. var element = this.dataList[i]
  130. if (item._id == element._id) {
  131. element.isSelected = !element.isSelected;
  132. }
  133. list.push(element)
  134. }
  135. console.log("XXXxXXX", list);
  136. this.dataList = list;
  137. this.analyseOptions = [];
  138. this.analyseValue = [];
  139. this.answerData = [];
  140. this.options = []
  141. this.questionList = []
  142. var testThemesList = [];
  143. for (var i = 0; i < this.dataList.length; i++) {
  144. var element = this.dataList[i]
  145. if (element.isSelected) {
  146. this.getCNCTestDetail(element)
  147. testThemesList.push(element);
  148. }
  149. }
  150. this.getCNCTestDetails(testThemesList);
  151. this.optionsX = []
  152. for (var i = 0; i < this.dataList.length; i++) {
  153. var element = this.dataList[i]
  154. if (element.isSelected) {
  155. this.getCNCTestDetailX(element)
  156. }
  157. }
  158. this.optionsY = []
  159. for (var i = 0; i < this.dataList.length; i++) {
  160. var element = this.dataList[i]
  161. if (element.isSelected) {
  162. this.getCNCTestDetailY(element)
  163. }
  164. }
  165. },
  166. async getCondition() {
  167. var testThemesIdList = [];
  168. for (var i = 0; i < this.options.length; i++) {
  169. var element = this.options[i]
  170. testThemesIdList.push(element.id);
  171. }
  172. let data = {
  173. testThemesIdList: testThemesIdList
  174. }
  175. api.condition(data).then((res) => {
  176. if (res.success) {
  177. console.log("success", res.single);
  178. this.condition = res.single;
  179. } else {
  180. console.log("error");
  181. }
  182. });
  183. },
  184. async getCNCTestDetails(testThemesList) {
  185. this.currentDate = timeFormat.getNowFormatDate();
  186. var testThemesIdList = [];
  187. for (var i = 0; i < testThemesList.length; i++) {
  188. var element = testThemesList[i]
  189. testThemesIdList.push(element._id);
  190. }
  191. let data = {
  192. testThemesIdList: testThemesIdList
  193. }
  194. api.answerData(data).then((res) => {
  195. if (res.success) {
  196. console.log("success", res);
  197. var answerData = res.single;
  198. for (var i = 0; i < answerData.questionList.length; i++) {
  199. var element = answerData.questionList[i]
  200. if (element.belongTestOrder <= testThemesIdList.length) {
  201. element.lable = testThemesList[element.belongTestOrder - 1].title;
  202. }
  203. }
  204. console.log("answerData", answerData);
  205. this.answerData = answerData;
  206. } else {
  207. console.log("error");
  208. }
  209. });
  210. },
  211. async getCNCTestDetail(item) {
  212. let data = {
  213. testThemesIdList: [item._id]
  214. }
  215. api.answerData(data).then((res) => {
  216. if (res.success) {
  217. console.log("success", res);
  218. var questionList = res.single.questionList;
  219. var children = []
  220. for (var i = 0; i < questionList.length; i++) {
  221. var question = questionList[i];
  222. var disabled = false;
  223. const found = this.value.find(element => element[1] == question.questionId);
  224. if (found) {
  225. disabled = true
  226. }
  227. children.push({ value: question.questionId, label: question.content, disabled: disabled })
  228. }
  229. var element = { value: item._id, label: item.title, children: children, id: item._id };
  230. this.options.push(element);
  231. this.questionList.push(questionList);
  232. } else {
  233. console.log("error");
  234. }
  235. });
  236. },
  237. async getCNCTestDetailX(item) {
  238. let data = {
  239. testThemesIdList: [item._id]
  240. }
  241. api.answerData(data).then((res) => {
  242. if (res.success) {
  243. console.log("success", res);
  244. var questionList = res.single.questionList;
  245. var children = []
  246. for (var i = 0; i < questionList.length; i++) {
  247. var question = questionList[i];
  248. var disabled = false;
  249. const foundX = this.optionsXValue.find(element => element[1] == question.questionId);
  250. if (foundX) {
  251. disabled = true
  252. }
  253. const foundY = this.optionsYValue.find(element => element[1] == question.questionId);
  254. if (foundY) {
  255. disabled = true
  256. }
  257. children.push({ value: question.questionId, label: question.content, disabled: disabled })
  258. }
  259. var element = { value: item._id, label: item.title, children: children, id: item._id };
  260. this.optionsX.push(element);
  261. } else {
  262. console.log("error");
  263. }
  264. });
  265. },
  266. async getCNCTestDetailY(item) {
  267. let data = {
  268. testThemesIdList: [item._id]
  269. }
  270. api.answerData(data).then((res) => {
  271. if (res.success) {
  272. console.log("success", res);
  273. var questionList = res.single.questionList;
  274. var children = []
  275. for (var i = 0; i < questionList.length; i++) {
  276. var question = questionList[i];
  277. var disabled = false;
  278. const foundX = this.optionsXValue.find(element => element[1] == question.questionId);
  279. if (foundX) {
  280. disabled = true
  281. }
  282. const foundY = this.optionsYValue.find(element => element[1] == question.questionId);
  283. if (foundY) {
  284. disabled = true
  285. }
  286. children.push({ value: question.questionId, label: question.content, disabled: disabled })
  287. }
  288. var element = { value: item._id, label: item.title, children: children, id: item._id };
  289. this.optionsY.push(element);
  290. } else {
  291. console.log("error");
  292. }
  293. });
  294. },
  295. handleChange(value, index) {
  296. console.log(value, index, this.oldValue);
  297. for (var i = 0; i < this.questionList.length; i++) {
  298. var questionList = this.questionList[i]
  299. for (var j = 0; j < questionList.length; j++) {
  300. if (value[1] == questionList[j].questionId) {
  301. if (this.oldValue.length >= index + 1) {
  302. // console.log("XXXXXXXXXXXXX");
  303. this.setOptionsDisabled(this.oldValue[index], false);
  304. }
  305. this.questionListSel[index] = questionList[j];
  306. }
  307. }
  308. }
  309. this.setOptionsDisabled(value, true);
  310. this.value[index] = value;
  311. this.oldValue[index] = value;
  312. this.checkList.splice(index, 1, []);
  313. this.questionChilds.splice(index, 1, []);
  314. },
  315. handleChangeX(value, index) {
  316. console.log("handleChangeX", value, index, this.optionsXOldValue);
  317. for (var i = 0; i < this.questionList.length; i++) {
  318. if (value[1] == this.questionList[i].questionId) {
  319. if (this.optionsXOldValue.length >= index + 1) {
  320. console.log("XXXXXXXXXXXXX");
  321. this.setOptionsDisabledXY(this.optionsXOldValue[index], false, 0);
  322. this.setOptionsDisabledXY(this.optionsYOldValue[index], false, 1);
  323. }
  324. }
  325. }
  326. this.setOptionsDisabledXY(value, true, 1);
  327. this.setOptionsDisabledXY(value, true, 0);
  328. this.optionsXValue[index] = value;
  329. this.optionsXOldValue[index] = value;
  330. },
  331. handleChangeY(value, index) {
  332. console.log("handleChangeX", value, index, this.optionsYOldValue);
  333. for (var i = 0; i < this.questionList.length; i++) {
  334. var questionList = this.questionList[i];
  335. for (var j = 0; j < questionList.length; j++) {
  336. if (value[1] == questionList[j].questionId) {
  337. if (this.optionsYOldValue.length >= index + 1) {
  338. this.setOptionsDisabledXY(this.optionsYOldValue[index], false, 1);
  339. this.setOptionsDisabledXY(this.optionsYOldValue[index], false, 0);
  340. }
  341. }
  342. }
  343. }
  344. this.setOptionsDisabledXY(value, true, 1);
  345. this.setOptionsDisabledXY(value, true, 0);
  346. this.optionsYValue[index] = value;
  347. this.optionsYOldValue[index] = value;
  348. },
  349. addfilterX() {
  350. this.filterXList.push('');
  351. },
  352. addfilterY() {
  353. this.filterYList.push('');
  354. },
  355. handleAnalyseChange(value) {
  356. console.log(value);
  357. },
  358. setOptionsDisabledXY(value, disabled, type = 0) {
  359. var newOptions = [];
  360. // console.log("setOptionsDisabledXY--0", value, disabled, type);
  361. var options = type == 0 ? this.optionsX : this.optionsY;
  362. for (var i = 0; i < options.length; i++) {
  363. var item = options[i];
  364. // console.log("setOptionsDisabledXY--1", value, disabled, type, item);
  365. // if (item.value == value[0]) {
  366. for (var j = 0; j < options[i].children.length; j++) {
  367. var children = []
  368. var element = options[i].children[j];
  369. // console.log("setOptionsDisabledXY--2", value, disabled, type, item, element.value, value[1]);
  370. if (element.value == value[1]) {
  371. element.disabled = disabled
  372. }
  373. children.push(element)
  374. }
  375. // }
  376. newOptions.push(item)
  377. }
  378. if (type == 0) {
  379. this.optionsX = newOptions;
  380. } else {
  381. this.optionsY = newOptions;
  382. }
  383. },
  384. setOptionsDisabled(value, disabled) {
  385. var newOptions = [];
  386. // console.log("setOptionsDisabled--0", value, disabled);
  387. for (var i = 0; i < this.options.length; i++) {
  388. var item = this.options[i];
  389. // console.log("setOptionsDisabledXY--1", value, disabled, item);
  390. // if (item.value == value[0]) {
  391. for (var j = 0; j < this.options[i].children.length; j++) {
  392. var children = []
  393. var element = this.options[i].children[j];
  394. // console.log("setOptionsDisabledXY--2", value, disabled, item, element.value, value[1]);
  395. if (element.value == value[1]) {
  396. element.disabled = disabled
  397. }
  398. children.push(element)
  399. }
  400. // }
  401. // console.log("XXXXXXX", item);
  402. newOptions.push(item)
  403. }
  404. this.options = newOptions;
  405. },
  406. addFilter() {
  407. this.filterList.push('');
  408. this.checkList.push([]);
  409. },
  410. delFilter(index) {
  411. if (this.value[index]) {
  412. this.setOptionsDisabled(this.value[index], false);
  413. }
  414. this.filterList.splice(index, 1);
  415. this.value.splice(index, 1);
  416. this.questionListSel.splice(index, 1);
  417. this.questionChilds.splice(index, 1);
  418. this.checkList.splice(index, 1);
  419. },
  420. projectCommand(command) {
  421. if (this.houseList.indexOf(command) == -1) {
  422. console.log("不存在");
  423. this.ownHouseName = "所属项目";
  424. } else {
  425. console.log("存在", command.houseName);
  426. this.ownHouseName = command.houseName;
  427. }
  428. this.getTestList();
  429. },
  430. analyseCommand(command) {
  431. console.log("XXXXXXX", command)
  432. if (command == -1) {
  433. this.analyseCommandSel = "全部";
  434. } else if (command == 0) {
  435. this.analyseCommandSel = "数据包";
  436. } else {
  437. this.analyseCommandSel = "区域";
  438. }
  439. // this.getTestList();
  440. },
  441. changequestionChild(checked, value, index) {
  442. console.log("XXXXXX", value, index, checked);
  443. var arr = this.questionChilds;
  444. if (this.questionChilds.length <= index) { // 没有
  445. if (checked) {
  446. console.log("选中");
  447. for (var i = 0; i < this.filterList.length; i++) {
  448. if (i < index) {
  449. if (this.questionChilds.length < index) {
  450. this.questionChilds.push([]);
  451. }
  452. }
  453. }
  454. this.questionChilds.push([value]);
  455. } else {
  456. console.log("取消选中")
  457. }
  458. } else { // 有
  459. console.log("有")
  460. var questionList = this.questionChilds[index];
  461. if (checked) {
  462. questionList.push(value)
  463. } else {
  464. var arr = questionList;
  465. for (var i = 0; i < questionList.length; i++) {
  466. var option = questionList[i];
  467. if (option.optionId == value.optionId) {
  468. arr.splice(i, 1);
  469. }
  470. }
  471. questionList = arr;
  472. }
  473. this.questionChilds[index] = questionList;
  474. }
  475. },
  476. getTestList() {
  477. let data = {
  478. "orderType": "",
  479. "ownHouseName": this.ownHouseName == "所属项目" ? '' : this.ownHouseName,
  480. "pageNo": 1,
  481. "pageSize": 100,
  482. "houseAnswerStatus": ""
  483. }
  484. api.testList(data).then((res) => {
  485. if (res.success) {
  486. this.total = res.pageModel.total;
  487. this.dataList = [];
  488. this.dataList.push(...res.pageModel.resultSet);
  489. this.dataList.forEach(element => {
  490. element.isSelected = false
  491. });
  492. console.log("success", this.dataList, res.pageModel);
  493. } else {
  494. console.log("error");
  495. }
  496. });
  497. },
  498. async getAnswerData() {
  499. this.filterStr = "";
  500. var conditionQuestionList = [];
  501. var testThemesIdList = [];
  502. for (var i = 0; i < this.questionChilds.length; i++) {
  503. var question = this.questionChilds[i];
  504. var value = this.value[i];
  505. var optionList = [];
  506. for (var j = 0; j < question.length; j++) {
  507. optionList.push({ optionId: question[j].optionId })
  508. this.filterStr += question[j].content + "/";
  509. }
  510. var conditionQuestion = { questionId: value[1], optionList: optionList }
  511. conditionQuestionList.push(conditionQuestion);
  512. }
  513. for (var i = 0; i < this.options.length; i++) {
  514. testThemesIdList.push(this.options[i].id);
  515. }
  516. this.filterStr = this.filterStr.substr(0, this.filterStr.length - 1)
  517. let data = {
  518. conditionQuestionList: conditionQuestionList,
  519. testThemesIdList: testThemesIdList
  520. }
  521. api.answerData(data).then((res) => {
  522. if (res.success) {
  523. console.log("success", res);
  524. var answerData = res.single;
  525. for (var i = 0; i < answerData.questionList.length; i++) {
  526. var element = answerData.questionList[i]
  527. console.log("found", found);
  528. if (element.belongTestOrder <= this.options.length) {
  529. element.lable = this.options[element.belongTestOrder - 1].label;
  530. }
  531. const found = conditionQuestionList.find(element => element.questionId == element.questionId);
  532. if (found) {
  533. if (found.questionId == element.questionId) {
  534. element.isFilter = true
  535. } else {
  536. element.isFilter = false
  537. }
  538. }
  539. }
  540. console.log("answerData", answerData);
  541. this.answerData = answerData;
  542. } else {
  543. console.log("error");
  544. }
  545. });
  546. },
  547. saveOnLine() {
  548. var checkList = [];
  549. for (var i = 0; i < this.questionChilds.length; i++) {
  550. var question = this.questionChilds[i]
  551. for (var j = 0; j < question.length; j++) {
  552. var option = question[j];
  553. var questionObj = this.questionListSel[i];
  554. checkList.push({ subOptionContent: option.content, subOptionId: option.optionId, subQuestionContent: questionObj.content, subQuestionId: questionObj.questionId })
  555. }
  556. }
  557. console.log("编辑数据包", checkList);
  558. this.$prompt("请数据包名称", "提保存筛选条件作为数据包", {
  559. confirmButtonText: "确定",
  560. cancelButtonText: "取消",
  561. inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
  562. inputErrorMessage: "数据包名称不为空",
  563. inputValue: this.title
  564. })
  565. .then(({ value }) => {
  566. let param = {
  567. checkList: checkList,
  568. analyseBagTitle: value,
  569. operator: "admin"
  570. };
  571. api.saveAnalyseBag(param).then(res => {
  572. if (res.success) {
  573. this.$message.success("保存成功");
  574. } else {
  575. this.$message.error("数据加载失败,请重试");
  576. }
  577. });
  578. })
  579. .catch(() => { });
  580. },
  581. async getCrossAnalyse() {
  582. var analyseBagIdList = [];
  583. var province = ""
  584. var city = ""
  585. var district = ""
  586. if (this.analyseCommandSel == "数据包") {
  587. if (this.analyseValue.length > 0) {
  588. analyseBagIdList.push(this.analyseValue[0])
  589. }
  590. } else if (this.analyseCommandSel == "区域") {
  591. if (this.analyseValue.length > 0) {
  592. province = this.analyseValue[0]
  593. } else if (this.analyseValue.length > 1) {
  594. city = this.analyseValue[1]
  595. } else if (this.analyseValue.length > 2) {
  596. district = this.analyseValue[2]
  597. }
  598. }
  599. var testThemesIdList = [];
  600. for (var i = 0; i < this.options.length; i++) {
  601. testThemesIdList.push(this.options[i].id);
  602. }
  603. var xlist = [];
  604. var ylist = [];
  605. for (var i = 0; i < this.questionList.length; i++) {
  606. var item = this.questionList[i];
  607. for (var j = 0; j < item.length; j++) {
  608. for (var m = 0; m < this.optionsXValue.length; m++) {
  609. var element = this.optionsXValue[m];
  610. if (item[j].questionId == element[1]) {
  611. const found = xlist.find(element => element.questionId == item[j].questionId);
  612. if (found === undefined) {
  613. xlist.push(item[j]);
  614. }
  615. }
  616. }
  617. for (var n = 0; n < this.optionsYValue.length; n++) {
  618. var element = this.optionsYValue[n];
  619. if (item[j].questionId == element[1]) {
  620. const found = ylist.find(element => element.questionId == item[j].questionId);
  621. if (found === undefined) {
  622. ylist.push(item[j]);
  623. }
  624. }
  625. }
  626. }
  627. }
  628. let data = {
  629. province: province,
  630. city: city,
  631. district: district,
  632. analyseBagIdList: analyseBagIdList,
  633. testThemesIdList: testThemesIdList,
  634. xlist: xlist,
  635. ylist: ylist
  636. }
  637. console.log("XXXXXX", data);
  638. api.crossAnalyse(data).then((res) => {
  639. if (res.success) {
  640. console.log("success", res.list);
  641. var crossAnalyse = res.list;
  642. this.crossAnalyse = []
  643. var result = [];
  644. var rowArr = [];
  645. for (var n = 0; n < crossAnalyse.length; n++) {
  646. var arrs = []
  647. var crossResult = crossAnalyse[n].crossResult;
  648. console.log("XXXXX", Object.keys(crossResult), Object.values(crossResult))
  649. rowArr = Object.keys(crossResult);
  650. var values = Object.values(crossResult)
  651. for (var m = 0; m < values.length; m++) {
  652. console.log("SSSSS", Object.keys(values[m]), Object.values(values[m]))
  653. arrs.push({ name: Object.keys(values[m]), value: Object.values(values[m]) })
  654. }
  655. result.push(arrs);
  656. }
  657. // console.log("AAAAAA", result);
  658. for (var x = 0; x < result.length; x++) {
  659. var qqq = result[x];
  660. var sss = [];
  661. for (var q = 0; q < qqq.length; q++) {
  662. sss.push({ name: rowArr[q], title: qqq[q].name, value: qqq[q].value })
  663. }
  664. this.crossAnalyse.push({ table: sss, data: [], question: null, name: null });
  665. }
  666. // console.log("SSSSS", this.crossAnalyse);
  667. for (var x = 0; x < this.crossAnalyse.length; x++) {
  668. var data = [];
  669. var top = this.crossAnalyse[x].table;
  670. for (var y = 0; y < top.length; y++) {
  671. var one = top[y].value;
  672. // console.log("one", top[y].name)
  673. var total = 0;
  674. for (var z = 0; z < one.length; z++) {
  675. var two = one[z];
  676. var p = total == 0 ? 0 : ((two / total) * 100).toFixed(0)
  677. if (top[y].title[z] != "total") {
  678. data.push({ time: top[y].name, type: top[y].title[z], value: two, total: p })
  679. } else {
  680. total = two
  681. }
  682. }
  683. }
  684. this.crossAnalyse[x].data = data;
  685. this.crossAnalyse[x].question = data;
  686. const found = this.optionsY.find(element => element.id == this.optionsYValue[x][0]);
  687. // console.log("XXXXXXXXXfound", found);
  688. if (found) {
  689. const children = found.children.find(element => element.value == this.optionsYValue[x][1]);
  690. // console.log("XXXXXXXXXchildren", children);
  691. if (children) {
  692. this.crossAnalyse[x].name = children.label
  693. }
  694. }
  695. }
  696. console.log("data", this.crossAnalyse);
  697. } else {
  698. console.log("error");
  699. }
  700. });
  701. },
  702. goToPreviewPage() {
  703. this.$router.push({
  704. name: 'previewPage',
  705. params: {
  706. chartData: this.chartData,
  707. answerData: this.answerData,
  708. currentDate: this.currentDate,
  709. options: this.options,
  710. filterStr: this.filterStr,
  711. isShowTable: this.isShowTable,
  712. isCrossAnalyse: this.isCrossAnalyse,
  713. crossAnalyse: this.crossAnalyse
  714. }
  715. })
  716. }
  717. },
  718. }