tools-online.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <div>
  3. <h2>在线指数还原工具</h2>
  4. <el-tabs class="mt-20" v-model="activeName" type="card" @tab-click="handleClick">
  5. <el-tab-pane label="单项计算" name="first">
  6. <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
  7. <el-menu-item :index="index.toString()" v-for="(item, index) in menuData" :key="index">{{ item.title }}
  8. </el-menu-item>
  9. </el-menu>
  10. <el-row class="mt-40">
  11. <el-col :span="10">
  12. <div class="TT-header">
  13. <p>{{ menuData[activeIndex * 1].title }}</p>
  14. <el-button type="primary" plain @click="handleClearBeforeValue">清除数据</el-button>
  15. </div>
  16. <el-input
  17. class="mt-20"
  18. type="textarea"
  19. :rows="10"
  20. placeholder="请输入内容"
  21. v-model="menuData[activeIndex * 1].beforeValue">
  22. </el-input>
  23. </el-col>
  24. <el-col class="mt-160" :span="2" :offset="1">
  25. <el-button type="primary" :disabled="isDisabled" @click="handleExchange">立即换算</el-button>
  26. </el-col>
  27. <el-col :span="10" :offset="1">
  28. <div class="TT-header">
  29. <p>{{ menuData[activeIndex * 1].afterLabel }}</p>
  30. <el-button type="primary" plain @click="handleClearAfterValue">清除数据</el-button>
  31. </div>
  32. <el-input
  33. class="mt-20"
  34. type="textarea"
  35. :rows="10"
  36. placeholder=""
  37. disabled
  38. v-model="menuData[activeIndex * 1].afterValue">
  39. </el-input>
  40. </el-col>
  41. </el-row>
  42. </el-tab-pane>
  43. <el-tab-pane label="组合计算" name="second">
  44. <el-row class="mt-40">
  45. <el-col :span="7">
  46. <div class="TT-header">
  47. <p>指数数值</p>
  48. <el-button type="primary" plain @click="handleClearGroupData(0)">清除数据</el-button>
  49. </div>
  50. <el-form class="mt-20" :label-position="'left'" ref="form" :model="formData0" label-width="90px">
  51. <el-form-item :label="item.label" v-for="(item, index) in formData0.data" :key="index">
  52. <el-input class="TT-input" type="number" placeholder="请输入内容" clearable
  53. v-model.number="formData0.data[index].value"></el-input>
  54. </el-form-item>
  55. </el-form>
  56. </el-col>
  57. <el-col class="mt-160" :span="2" :offset="1">
  58. <el-button type="primary" :disabled="isDisabled" @click="onSubmit">立即换算</el-button>
  59. </el-col>
  60. <el-col :span="13" :offset="1">
  61. <el-row>
  62. <el-col :span="11">
  63. <div class="TT-header">
  64. <p>实际数据</p>
  65. <el-button type="primary" plain @click="handleClearGroupData(1)">清除数据</el-button>
  66. </div>
  67. <el-form class="mt-20" :label-position="'left'" ref="form" :model="formData1" label-width="90px">
  68. <el-form-item :label="item.label" v-for="(item, index) in formData1.data" :key="index">
  69. <el-input placeholder="" disabled v-model="formData1.data[index].value"></el-input>
  70. </el-form-item>
  71. </el-form>
  72. </el-col>
  73. <el-col :span="11" :offset="2">
  74. <div class="TT-header">
  75. <p>高阶数据</p>
  76. <el-button type="primary" plain @click="handleClearGroupData(2)">清除数据</el-button>
  77. </div>
  78. <el-form class="mt-20" :label-position="'left'" ref="form" :model="formData2" label-width="90px">
  79. <el-form-item :label="item.label" v-for="(item, index) in formData2.data" :key="index">
  80. <el-input placeholder="" disabled v-model="formData2.data[index].value"></el-input>
  81. </el-form-item>
  82. </el-form>
  83. </el-col>
  84. </el-row>
  85. </el-col>
  86. </el-row>
  87. </el-tab-pane>
  88. </el-tabs>
  89. </div>
  90. </template>
  91. <script>
  92. export default {
  93. name: 'toolsOnline',
  94. data () {
  95. return {
  96. activeName: 'first',
  97. menuData: [
  98. {
  99. title: '关键词页面指数【流量指数】',
  100. afterLabel: '支付件数',
  101. beforeValue: '',
  102. afterValue: ''
  103. },
  104. {
  105. title: '流量指数',
  106. afterLabel: '访客数',
  107. beforeValue: '',
  108. afterValue: ''
  109. },
  110. {
  111. title: '交易指数',
  112. afterLabel: '支付金额',
  113. beforeValue: '',
  114. afterValue: ''
  115. },
  116. {
  117. title: '搜索人气',
  118. afterLabel: '搜索人数',
  119. beforeValue: '',
  120. afterValue: ''
  121. },
  122. {
  123. title: '加购人气',
  124. afterLabel: '加购人数',
  125. beforeValue: '',
  126. afterValue: ''
  127. },
  128. {
  129. title: '收藏人气',
  130. afterLabel: '收藏人数',
  131. beforeValue: '',
  132. afterValue: ''
  133. },
  134. {
  135. title: '客群指数',
  136. afterLabel: '支付买家数',
  137. beforeValue: '',
  138. afterValue: ''
  139. },
  140. {
  141. title: '支付转化率指数',
  142. afterLabel: '支付转化率',
  143. beforeValue: '',
  144. afterValue: ''
  145. },
  146. {
  147. title: '流失人气',
  148. afterLabel: '流失人数',
  149. beforeValue: '',
  150. afterValue: ''
  151. },
  152. {
  153. title: '搜索热度',
  154. afterLabel: '搜索次数',
  155. beforeValue: '',
  156. afterValue: ''
  157. },
  158. {
  159. title: '点击人气',
  160. afterLabel: '点击人数',
  161. beforeValue: '',
  162. afterValue: ''
  163. },
  164. {
  165. title: '点击热度',
  166. afterLabel: '点击次数',
  167. beforeValue: '',
  168. afterValue: ''
  169. },
  170. {
  171. title: '咨询次数指数',
  172. afterLabel: '咨询客服次数',
  173. beforeValue: '',
  174. afterValue: ''
  175. },
  176. {
  177. title: '客服支付指数',
  178. afterLabel: '客服支付金额',
  179. beforeValue: '',
  180. afterValue: ''
  181. },
  182. {
  183. title: '客服客单价指数',
  184. afterLabel: '客服客单价',
  185. beforeValue: '',
  186. afterValue: ''
  187. },
  188. {
  189. title: '人工平均响应时长指数',
  190. afterLabel: '人工平均响应时长',
  191. beforeValue: '',
  192. afterValue: ''
  193. },
  194. {
  195. title: '客服询单-转化率指数',
  196. afterLabel: '客服支付买家数/询单人数',
  197. beforeValue: '',
  198. afterValue: ''
  199. }
  200. ],
  201. activeIndex: '0',
  202. formData0: {
  203. data: [
  204. {
  205. key: 'liuliang',
  206. label: '流量指数:',
  207. value: ''
  208. },
  209. {
  210. key: 'jiaoyi',
  211. label: '交易指数:',
  212. value: ''
  213. },
  214. {
  215. key: 'sousuorenqi',
  216. label: '搜索人气:',
  217. value: ''
  218. },
  219. {
  220. key: 'shoucangrenqi',
  221. label: '收藏人气:',
  222. value: ''
  223. },
  224. {
  225. key: 'jiagourenqi',
  226. label: '加购人气',
  227. value: ''
  228. },
  229. {
  230. key: 'zhifuzhuanhualv',
  231. label: '转换指数:',
  232. value: ''
  233. }
  234. ]
  235. },
  236. formData1: {
  237. data: [
  238. {
  239. key: 'liuliang',
  240. label: '访客数:',
  241. value: ''
  242. },
  243. {
  244. key: 'jiaoyi',
  245. label: '交易金额:',
  246. value: ''
  247. },
  248. {
  249. key: 'sousuorenqi',
  250. label: '搜索人数:',
  251. value: ''
  252. },
  253. {
  254. key: 'shoucangrenqi',
  255. label: '收藏人数:',
  256. value: ''
  257. },
  258. {
  259. key: 'jiagourenqi',
  260. label: '加购人数:',
  261. value: ''
  262. },
  263. {
  264. key: 'zhifuzhuanhualv',
  265. label: '转化率:',
  266. value: ''
  267. }
  268. ]
  269. },
  270. formData2: {
  271. data: [
  272. {
  273. key: 'kedanjia',
  274. label: '客单价:',
  275. value: ''
  276. },
  277. {
  278. key: 'sousuozhanbi',
  279. label: '搜索占比:',
  280. value: ''
  281. },
  282. {
  283. key: 'shoucanglv',
  284. label: '收藏率:',
  285. value: ''
  286. },
  287. {
  288. key: 'jiagoulv',
  289. label: '加购率:',
  290. value: ''
  291. }
  292. ]
  293. },
  294. isDisabled: false
  295. }
  296. },
  297. methods: {
  298. handleClick (tab, event) {
  299. console.log(tab, event)
  300. },
  301. handleSelect (key, keyPath) {
  302. this.activeIndex = key
  303. },
  304. handleClearBeforeValue () {
  305. const index = this.activeIndex * 1
  306. this.$set(this.menuData[index], 'beforeValue', '')
  307. },
  308. handleClearAfterValue () {
  309. const index = this.activeIndex * 1
  310. this.$set(this.menuData[index], 'afterValue', '')
  311. },
  312. handleClearGroupData (index) {
  313. const formData = this[`formData${index}`]
  314. if (!formData) {
  315. return
  316. }
  317. formData.data.forEach((item, idx) => {
  318. this.$set(this[`formData${index}`]['data'][idx], 'value', '')
  319. })
  320. },
  321. handleExchange () {
  322. const activeIndex = this.activeIndex * 1
  323. const { title, beforeValue } = this.menuData[activeIndex]
  324. let postData = {
  325. number: beforeValue, // 指数值
  326. type: title === '支付转化率指数' ? 7 : 1 // 指数类型(7为支付指数转化 其他都为1)
  327. }
  328. if (this.isDisabled) {
  329. return
  330. }
  331. this.isDisabled = true
  332. this.$http({
  333. url: this.$http.adornUrl('/tb/exchange'),
  334. method: 'post',
  335. data: this.$http.adornData(postData)
  336. }).then(({ data }) => {
  337. this.isDisabled = false
  338. if (data.status) {
  339. const { numberData } = data.data
  340. this.$set(this.menuData[activeIndex], 'afterValue', numberData)
  341. return
  342. }
  343. this.$message.error(data.msg)
  344. }).catch(() => {
  345. this.isDisabled = false
  346. })
  347. },
  348. onSubmit () {
  349. const data = this.formData0.data
  350. let postData = {}
  351. data.forEach(item => {
  352. postData[item.key] = item.value
  353. })
  354. if (this.isDisabled) {
  355. return
  356. }
  357. this.isDisabled = true
  358. this.$http({
  359. url: this.$http.adornUrl('/tb/zhishuzhuanhua'),
  360. method: 'post',
  361. data: this.$http.adornData(postData)
  362. }).then(({ data }) => {
  363. this.isDisabled = false
  364. if (data.status) {
  365. const _keys = Object.keys(data.data)
  366. this.formData1.data.forEach((item, index) => {
  367. if (_keys.includes(item.key)) {
  368. this.$set(this.formData1.data[index], 'value', data.data[item.key])
  369. }
  370. })
  371. this.formData2.data.forEach((item, index) => {
  372. if (_keys.includes(item.key)) {
  373. this.$set(this.formData2.data[index], 'value', data.data[item.key])
  374. }
  375. })
  376. return
  377. }
  378. this.$message.error(data.msg)
  379. }).catch(() => {
  380. this.isDisabled = false
  381. })
  382. }
  383. }
  384. }
  385. </script>
  386. <style lang="scss" scoped>
  387. .mt-20 {
  388. margin-top: 20px;
  389. }
  390. .mt-40 {
  391. margin-top: 40px;
  392. }
  393. .mt-160 {
  394. margin-top: 160px;
  395. }
  396. .TT-header {
  397. display: flex;
  398. justify-content: space-between;
  399. p {
  400. line-height: 36px;
  401. font-size: 18px;
  402. }
  403. }
  404. .TT-origin {
  405. li {
  406. display: flex;
  407. align-items: center;
  408. }
  409. }
  410. </style>