commodityChartBase.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. <template>
  2. <div class="comodity-chart-container pub-chart-box" v-if="showData">
  3. <span
  4. class="slide-icon slide-right"
  5. @click="isSlideLeft = !isSlideLeft"
  6. v-show="isSlideLeft"
  7. >
  8. <i class="el-icon-d-arrow-right"></i>
  9. </span>
  10. <div class="data-sheet-main" id="box">
  11. <div class="main-left left" id="left" v-show="!isSlideLeft">
  12. <div class="datasheet_top">
  13. <el-button v-permission="permissionBtn.productPricePermission.goodsPrice_priceLine"
  14. type="primary" @click="goAddChart('price')">添加价格曲线</el-button>
  15. <el-button v-permission="permissionBtn.productPricePermission.goodsPrice_incomeLine"
  16. type="primary" @click="goAddChart('profit')">添加利润曲线</el-button>
  17. </div>
  18. <div class="search-cont">
  19. <el-checkbox v-model="isShowMe"
  20. v-if="permissionBtn.isShowBtn('productPricePermission','goodsPrice_onlyMine')"
  21. @change="() => { getTreeData();getPublicList() }">只看我的</el-checkbox>
  22. <el-select
  23. v-model="search_txt"
  24. v-loadMore="searchLoad"
  25. :filterable="!search_txt"
  26. remote
  27. clearable
  28. placeholder="请输入图表名称"
  29. style="width: 100%; margin-top: 20px"
  30. :remote-method="searchHandle"
  31. @click.native="inputFocusHandle"
  32. >
  33. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  34. <el-option
  35. v-for="item in searchOptions"
  36. :key="item.ChartInfoId"
  37. :label="item.ChartName"
  38. :value="item.ChartInfoId"
  39. >
  40. </el-option>
  41. </el-select>
  42. </div>
  43. <div class="tree-cont">
  44. <el-tree
  45. ref="treeRef"
  46. class="target_tree"
  47. :data="treeData"
  48. node-key="UniqueCode"
  49. :props="defaultProp"
  50. :allow-drag="canDragHandle"
  51. :allow-drop="canDropHandle"
  52. :current-node-key="select_node"
  53. :default-expanded-keys="defaultShowNodes"
  54. draggable
  55. :expand-on-click-node="false"
  56. check-strictly
  57. empty-text="暂无分类"
  58. @node-expand="handleNodeExpand"
  59. @node-collapse="handleNodeCollapse"
  60. @current-change="nodeChange"
  61. @node-drop="dropOverHandle"
  62. @node-drag-end="dropMouseLeave"
  63. @node-drag-leave="dropMouseLeave"
  64. @node-drag-enter="dropMouseOver"
  65. >
  66. <span class="custom-tree-node" slot-scope="{ node, data }">
  67. <el-input
  68. ref="editVal"
  69. style="width: 90px"
  70. placeholder="请输入值"
  71. class="label-input"
  72. v-model="new_label"
  73. v-if="data.isEdit&&permissionBtn.isShowBtn('productPricePermission','goodsPrice_classifyOpt_edit')"
  74. @blur="changeValue(data)"
  75. />
  76. <span
  77. @dblclick.stop="handleDblClick(data)"
  78. v-else
  79. class="text_oneLine node_label"
  80. :style="`width:${
  81. (select_node === data.UniqueCode && node.Nodewidth) || ''
  82. }`"
  83. >
  84. <span>{{ data.ChartClassifyName }}</span>
  85. </span>
  86. <span
  87. style="display: flex; align-items: center"
  88. v-if="select_node === data.UniqueCode"
  89. >
  90. <img
  91. src="~@/assets/img/data_m/move_ico.png"
  92. alt=""
  93. style="width: 14px; height: 14px; margin-right: 8px"
  94. />
  95. <img
  96. src="~@/assets/img/set_m/edit.png"
  97. alt=""
  98. style="width: 15px; height: 14px; margin-right: 8px"
  99. @click.stop="editNode(node, data)"
  100. v-if="!data.ChartInfoId&&permissionBtn.isShowBtn('productPricePermission','goodsPrice_classifyOpt_edit')"
  101. />
  102. <img
  103. slot="reference"
  104. src="~@/assets/img/set_m/del.png"
  105. alt=""
  106. style="width: 14px; height: 14px"
  107. @click.stop="removeNode(node, data)"
  108. v-if="!data.ChartInfoId&&permissionBtn.isShowBtn('productPricePermission','goodsPrice_classifyOpt_delete')"
  109. />
  110. </span>
  111. </span>
  112. </el-tree>
  113. <div
  114. class="noDepart"
  115. @click="addLevelOneHandle"
  116. v-if="permissionBtn.isShowBtn('productPricePermission','goodsPrice_classifyOpt_edit')"
  117. >
  118. <img
  119. src="~@/assets/img/set_m/add_ico.png"
  120. alt=""
  121. style="width: 16px; height: 16px; margin-right: 10px"
  122. />
  123. <span>添加图表分类</span>
  124. </div>
  125. </div>
  126. <span
  127. class="move-btn resize"
  128. v-drag
  129. id="resize"
  130. @mousemove="dynamicNode && resetNodeStyle(dynamicNode)"
  131. ></span>
  132. <span class="slide-icon slide-left" @click="isSlideLeft = !isSlideLeft">
  133. <i class="el-icon-d-arrow-left"></i>
  134. </span>
  135. </div>
  136. <div class="main-right" id="right" :style="isSlideLeft ? 'width:100%' : 'width:80%'">
  137. <!-- 图表详情 -->
  138. <div class="chart-detail-wrapper" v-if="chartInfo.ChartInfoId">
  139. <el-row class="bottom-min">
  140. <el-col
  141. :span="21"
  142. style="padding: 20px 0;"
  143. >
  144. <div class="chartEn-mark" v-show="chartInfo.IsEnChart" style="top: 0;left: 0;">En</div>
  145. <div class="chart-show-cont" v-if="!chartInfo.WarnMsg">
  146. <div class="chartWrapper" id="chartWrapper">
  147. <h2 class="chart-title">{{ chartInfo.ChartName }}</h2>
  148. <Chart
  149. :options="options"
  150. minHeight="440px"
  151. height="500px"
  152. ref="chartRef"
  153. />
  154. <!-- 上下限 -->
  155. <div class="range-cont left">
  156. <el-input
  157. style="width: 60px; display: block"
  158. size="mini"
  159. type="number"
  160. placeholder="上限"
  161. :disabled="!permissionBtn.isShowBtn('productPricePermission','goodsPrice_editLimit')"
  162. v-model="chartLimit.max"
  163. @change="setCommodityChart"
  164. />
  165. <el-input
  166. class="min-data-input"
  167. size="mini"
  168. type="number"
  169. placeholder="下限"
  170. :disabled="!permissionBtn.isShowBtn('productPricePermission','goodsPrice_editLimit')"
  171. v-model="chartLimit.min"
  172. @change="setCommodityChart"
  173. />
  174. </div>
  175. </div>
  176. <span class="chart-author">作者:{{ chartInfo.SysUserRealName}}</span>
  177. </div>
  178. <!-- 异常显示 -->
  179. <p class="error-tip" style="min-height: 400px;" v-if="chartInfo.WarnMsg">{{chartInfo.WarnMsg}}</p>
  180. </el-col>
  181. <el-col :span="3" style="position: absolute;height: 100%;right: 0;">
  182. <!-- 操作 -->
  183. <chartHandlesWrap
  184. :chartInfo="chartInfo"
  185. :linkUrl="linkUrl"
  186. @copyChartConfirm="copyChartConfirm"
  187. @addMychartHandle="addMychartHandle"
  188. @refreshHandle="refreshHandle"
  189. @saveChartHandle="saveChartHandle"
  190. @saveChartOtherHandle="saveChartOtherHandle"
  191. @editChartHandle="editChartHandle"
  192. @openEnNameDia="openEnNameDia"
  193. @delChartHandle="delChartHandle"
  194. />
  195. </el-col>
  196. </el-row>
  197. </div>
  198. <!-- 列表 -->
  199. <chartListWrap
  200. v-else
  201. :total="chart_total"
  202. :list="chartList"
  203. @loadMoreHandle="loadMoreHandle"
  204. @detailShowHandle="detailShowHandle"
  205. @addMychartHandle="addMychartHandle"
  206. ref="chartListWrap"
  207. />
  208. </div>
  209. </div>
  210. <!-- 分类弹窗 -->
  211. <classify-dia
  212. :isOpenDialog.sync="classifyDia"
  213. :title="dialog_title"
  214. :form="classifyForm"
  215. @successCallback="getTreeData"
  216. />
  217. <!-- 加入我的图库弹窗 -->
  218. <addMyClassifyDia
  219. :isAddMyDialog="isAddMyChart"
  220. :add_id="add_chart_id"
  221. :add_ids="add_ids"
  222. @cancel="isAddMyChart = false"
  223. @addSuccess="addMySuccess"
  224. />
  225. <!-- 图表另存 -->
  226. <SaveChartOther
  227. :show.sync="isShowSaveOther"
  228. fromType="chartsetting"
  229. source="good_price"
  230. :data="chartInfo"
  231. @ensure="getTreeData"
  232. />
  233. <!-- 输入英文指标弹窗 -->
  234. <set-en-name-dia
  235. :isOpenDialog="setEnName"
  236. :formData="formItemArray"
  237. @cancel="setEnName=false"
  238. @updateEnName="updateEnName"
  239. />
  240. </div>
  241. </template>
  242. <script>
  243. import { dataBaseInterface } from '@/api/api.js';
  244. import futuresInterface from '@/api/modules/futuresBaseApi';
  245. import leftMixin from './mixins/classifyMixin';
  246. import Chart from '@/views/dataEntry_manage/components/chart';
  247. import changeLang from "@/views/dataEntry_manage/components/changeLang.vue"
  248. import classifyDia from '@/views/datasheet_manage/components/sheetClassifyDia.vue';
  249. import addMyClassifyDia from '@/views/dataEntry_manage/components/addMyClassifyDia';
  250. import SaveChartOther from '@/views/dataEntry_manage/components/SaveChartOther';
  251. import setEnNameDia from '@/views/dataEntry_manage/components/setEnNameDia.vue'
  252. import { chartSetMixin } from '@/views/dataEntry_manage/mixins/chartPublic';
  253. import { copyOtherOptions } from '@/utils/defaultOptions';
  254. export default {
  255. components: {
  256. changeLang,
  257. classifyDia,
  258. Chart,
  259. addMyClassifyDia,
  260. SaveChartOther,
  261. setEnNameDia
  262. },
  263. mixins:[ leftMixin,chartSetMixin ],
  264. computed: {
  265. /* 分享地址 */
  266. linkUrl() {
  267. const LINK_CHART_URL = this.$setting.dynamicOutLinks.ChartViewUrl+'/chartshow';
  268. return `${LINK_CHART_URL}?code=${this.chartInfo.UniqueCode}&fromType=share?&lang=${this.currentLang}`
  269. }
  270. },
  271. data () {
  272. return {
  273. showData: false,
  274. refreshLoading: false,
  275. isShowMe: false,
  276. search_txt: '',
  277. searchOptions:[],
  278. isSlideLeft: false,//左侧分类收起
  279. select_node: '',//节点唯一标识code
  280. select_classify: '',
  281. new_label:'',//双击修改的value
  282. treeData: [], //分类数据
  283. defaultShowNodes: [], //展开节点
  284. defaultProp: {
  285. label: 'ChartClassifyName',
  286. children: 'Children',
  287. }, //树结构配置项
  288. dynamicNode: null,
  289. /* 分类弹窗 */
  290. dialog_title:'',
  291. classifyDia: false, //
  292. classifyForm: {},
  293. select_id: '',//选中的图表id
  294. chartInfo: {},
  295. chart_title:'',//图表标题 双击标题修改时来存储最新值
  296. isAddMyChart: false, //加入图库弹窗
  297. add_chart_id: 0, //要加入的图表
  298. add_ids:[],//加入时已有的分类
  299. /* 图表列表 */
  300. publicHaveMove: true,//是否还有列表数据
  301. chartList: [],
  302. chart_total: 0,
  303. chart_page: 1,
  304. chart_pages_size: 16,
  305. search_page: 1,
  306. search_have_more: false,
  307. current_search:'',
  308. };
  309. },
  310. watch: {
  311. /* 设置动态右侧区域宽度 */
  312. isSlideLeft(newval) {
  313. this.$nextTick(() => {
  314. this.reloadRightWid();
  315. });
  316. },
  317. /* 图表id */
  318. select_id(newval) {
  319. if(newval) {
  320. this.currentLang = 'ch';
  321. this.getDetailHandle();
  322. }else {
  323. this.chartInfo = {};
  324. }
  325. },
  326. select_classify(newval) {
  327. if(this.$refs.chartListWrap) this.$refs.chartListWrap.$refs.listRef.scrollTop = 0;
  328. if(newval) {
  329. this.chart_page = 1;
  330. this.getPublicList()
  331. }
  332. },
  333. /* 搜索关键词 */
  334. search_txt(newval) {
  335. if(newval) {
  336. let search_obj = this.searchOptions.find(_ => _.ChartInfoId === newval);
  337. let deep_arr = _.cloneDeep(this.treeData);
  338. // 查找图表的分类父级id
  339. let arr = this.findParentNodeHandle(deep_arr, search_obj.UniqueCode).slice(1).reverse(); // 父的父的父-父的父-父
  340. this.defaultShowNodes = arr;
  341. this.select_node = search_obj.UniqueCode;
  342. this.$refs.treeRef.setCurrentKey(this.select_node);
  343. // 重置筛选状态
  344. this.select_id = newval;
  345. }
  346. }
  347. },
  348. methods: {
  349. /* 添加图表 */
  350. goAddChart(scence) {
  351. if(!this.treeData.length) return this.$message.warning('请先添加分类');
  352. this.$router.push({ path: '/addCommodityChart',query: { scence } });
  353. },
  354. /* 获取分类 */
  355. getTreeData(params=null) {
  356. futuresInterface.classifyList({IsShowMe:this.isShowMe}).then(res => {
  357. const { Ret,Data } = res;
  358. if(Ret !== 200) return
  359. this.showData = true;
  360. this.treeData = Data.AllNodes || [];
  361. this.$nextTick(() => {
  362. /* 新增完成后 处理树展开和选中 */
  363. params && this.selectCurrentNode(params);
  364. });
  365. })
  366. },
  367. /* 搜索 */
  368. searchHandle(query) {
  369. this.search_page = 1;
  370. this.current_search = query;
  371. this.searchApi(this.current_search)
  372. },
  373. searchApi(query,page=1) {
  374. /* 查找列表 */
  375. futuresInterface
  376. .searchChart({
  377. Keyword: query,
  378. IsShowMe:this.isShowMe,
  379. CurrentIndex: page
  380. })
  381. .then((res) => {
  382. if (res.Ret !== 200) return
  383. const { List,Paging } = res.Data;
  384. this.search_have_more = page < Paging.Pages;
  385. this.searchOptions = page === 1 ? List : [...this.searchOptions,...List];
  386. });
  387. },
  388. /* 聚焦获取当前检索 */
  389. inputFocusHandle(e) {
  390. this.search_page = 1;
  391. this.current_search = e.target.value;
  392. if(this.current_search) {
  393. this.searchApi(this.current_search)
  394. }else {
  395. this.searchOptions = [];
  396. }
  397. },
  398. searchLoad() {
  399. if(!this.search_have_more) return;
  400. this.searchApi(this.current_search,++this.search_page);
  401. },
  402. /* 选中分类变化时 */
  403. nodeChange({ UniqueCode,ChartInfoId,ChartClassifyId },node) {
  404. this.search_txt = '';
  405. this.select_node = UniqueCode;
  406. this.select_classify = !ChartInfoId ? ChartClassifyId : 0;
  407. // if(this.select_id !== ChartInfoId) {
  408. this.select_id = ChartInfoId || 0;
  409. // }
  410. this.resetNodeStyle(node);
  411. this.dynamicNode = node;
  412. },
  413. /* 添加一级目录 */
  414. addLevelOneHandle() {
  415. this.dialog_title = '添加';
  416. this.classifyForm = {
  417. classify_name: '',
  418. }
  419. this.classifyDia = true;
  420. },
  421. /* 编辑节点 */
  422. editNode(node, { ChartClassifyName,ChartClassifyId }) {
  423. this.dialog_title = '编辑';
  424. /* 编辑目录 */
  425. this.classifyForm = {
  426. classify_name: ChartClassifyName,
  427. classify_id: ChartClassifyId,
  428. };
  429. this.classifyDia = true;
  430. },
  431. /* 删除节点校验 */
  432. async removeNode(node, { ChartClassifyId,ChartInfoId }) {
  433. const { Data } = await futuresInterface.classifyDelCheck({ ChartClassifyId })
  434. const { DeleteStatus } = Data;
  435. DeleteStatus === 1
  436. ? this.$confirm('该分类下关联表图表不可删除', '删除失败', {
  437. confirmButtonText: '知道了',
  438. showCancelButton: false,
  439. type: 'error',
  440. }) : DeleteStatus === 0
  441. ? this.$confirm('确定删除当前分类吗?', '提示', {
  442. confirmButtonText: '确定',
  443. cancelButtonText: '取消',
  444. type: 'warning',
  445. }).then(() => {
  446. this.delApi(ChartClassifyId,ChartInfoId)
  447. }): null;
  448. },
  449. /* 删除方法 */
  450. delApi(ChartClassifyId,ChartInfoId,type='') {
  451. futuresInterface
  452. .classifyDel({
  453. ChartClassifyId,
  454. ChartInfoId
  455. })
  456. .then((res) => {
  457. if (res.Ret !== 200) return
  458. this.$message.success(res.Msg);
  459. if (!res.Data.ChartInfoId) this.select_id = '';
  460. //删除自动显示下一张
  461. type=='del_chart' && res.Data.ChartInfoId
  462. ? this.getTreeData({
  463. code: res.Data.UniqueCode,
  464. id: res.Data.ChartInfoId
  465. })
  466. : this.getTreeData();
  467. });
  468. },
  469. /* 分类成功回调 */
  470. classifyCallback(type) {
  471. this.getTreeData();
  472. if (type === 'add') {
  473. //新增分类完成之后,展开父节点显示刚新增的分类,若已展开节点则不做处理
  474. let code = this.add_parent_id;
  475. let flag = this.defaultShowNodes.some(item => item === code);
  476. // console.log(flag)
  477. !flag && this.defaultShowNodes.push(code);
  478. this.add_parent_id = '';
  479. }
  480. },
  481. /* 展开对应菜单 显示详情 */
  482. detailShowHandle({ UniqueCode, ChartInfoId }) {
  483. let params = {
  484. code: UniqueCode,
  485. id: ChartInfoId
  486. };
  487. this.selectCurrentNode(params);
  488. this.select_classify = 0;
  489. },
  490. /* 保存图表 */
  491. saveChartHandle: _.debounce(async function() {
  492. const { Ret } = await futuresInterface.chartSave({
  493. ChartInfoId: this.chartInfo.ChartInfoId,
  494. LeftMin: String(this.chartLimit.min),
  495. LeftMax: String(this.chartLimit.max),
  496. })
  497. if(Ret!==200) return
  498. this.$message.success('保存成功');
  499. this.getTreeData();
  500. //关联图表和图片
  501. this.setChartImage();
  502. },300),
  503. /* 点击保存时关联图表和截取的图片 */
  504. setChartImage() {
  505. let svg = this.$refs.chartRef.chart.getSVG({
  506. chart:{
  507. width: 340,
  508. height: 230,
  509. }
  510. });
  511. let form = new FormData();
  512. form.append('Img', svg);
  513. this.setImageHandle(form);
  514. },
  515. async setImageHandle(form) {
  516. let { Data } = await dataBaseInterface.uploadImgSvg(form);
  517. await dataBaseInterface.setChartImage({
  518. ChartInfoId: this.selected_chartid,
  519. ImageUrl: Data.ResourceUrl,
  520. });
  521. },
  522. copyChartConfirm(type) {
  523. type !== 'url' && this.copyChartHandle(type)
  524. if(this.currentLang=='en'){
  525. // 是否所有数据都填写完
  526. let flag=true
  527. // 是否有英文表格名称
  528. if(!this.chartInfo.ChartNameEn || !this.chartInfo.UnitEn) flag = false;
  529. if(!flag){
  530. this.$confirm('英文名称未输入完整,分享图表上可能出现空名称的情况,确定继续分享吗?', '提示', {
  531. confirmButtonText: '确定',
  532. cancelButtonText: '取消',
  533. type: 'warning',
  534. })
  535. .then(() => {
  536. if(type==='url'){
  537. const input = document.createElement('input')
  538. input.setAttribute('readonly','readonly')
  539. input.value = this.linkUrl
  540. document.body.appendChild(input)
  541. input.select();
  542. document.execCommand('copy');
  543. document.body.removeChild(input);
  544. this.$message.success('复制链接成功')
  545. }
  546. })
  547. .catch(() => {});
  548. }else{
  549. type=='url' && this.shareUrl()
  550. }
  551. }else{
  552. type=='url' && this.shareUrl()
  553. }
  554. },
  555. /* 点击复制先用canvas画出 转成图片在放到粘贴板中 */
  556. copyChartHandle:_.debounce(function(type){{
  557. let chartsName = this.currentLang=='ch'?this.chartInfo.ChartName:this.chartInfo.ChartNameEn
  558. let { heightNum, widthNum , newTitle , dynamic_copyOptions} = this.dynamicWidthAndHeight(type,this.chartInfo.ChartType,chartsName,this.commodityChartData.length)
  559. const chartType = 'seasonLegend';
  560. // 英文转SVG设置变动
  561. if(this.currentLang == 'en'){
  562. // 如果竖轴坐标单位为'英文单位',表示客户没填,转成svg时置为空
  563. this.$refs.chartRef.chart.options.yAxis.forEach(it => {
  564. if(it.title.text == '英文单位') it.title.text=''
  565. });
  566. }
  567. let svg = this.$refs.chartRef.chart.getSVG({
  568. chart:{
  569. width:widthNum,
  570. height:heightNum,
  571. backgroundColor:"rgba(255, 255, 255, 0)",
  572. },
  573. title: {
  574. text: newTitle,
  575. margin: 10,
  576. style: {
  577. fontSize: '18px'
  578. }
  579. },
  580. legend:{
  581. ...copyOtherOptions[chartType],
  582. ...dynamic_copyOptions[chartType]
  583. }
  584. });
  585. this.copyBlobItem(widthNum,heightNum,svg,type);
  586. }
  587. },500),
  588. /* 分享图表 */
  589. shareUrl() {
  590. var clipboard = new this.Clipboard('.shareLink')
  591. clipboard.on('success', e => {
  592. console.log(e);
  593. this.$message.success('复制链接成功')
  594. e.clearSelection() // 释放内存
  595. clipboard.destroy()
  596. })
  597. // // 浏览器不支持
  598. clipboard.on('error', e => {
  599. this.$message.warning('浏览器暂不支持')
  600. // 释放内存
  601. clipboard.destroy()
  602. })
  603. },
  604. /* 获取图表列表 */
  605. getPublicList() {
  606. futuresInterface.getChartList({
  607. CurrentIndex: this.chart_page,
  608. PageSize: this.chart_pages_size,
  609. ChartClassifyId: this.select_classify || 0,
  610. IsShowMe: this.isShowMe
  611. }).then(res => {
  612. if(res.Ret !== 200) return
  613. this.publicHaveMove = res.Data
  614. ? this.chart_page < res.Data.Paging.Pages
  615. : false;
  616. this.chartList = res.Data
  617. ? this.chart_page === 1
  618. ? res.Data.List
  619. : [...this.chartList, ...res.Data.List]
  620. : [];
  621. this.chart_total = res.Data ? res.Data.Paging.Totals : 0;
  622. })
  623. },
  624. /* 加载更多 */
  625. loadMoreHandle: _.throttle(function() {
  626. let scrollTop = this.$refs.chartListWrap.$refs.listRef.scrollTop;
  627. let clientHeight = this.$refs.chartListWrap.$refs.listRef.clientHeight;
  628. let scrollHeight = this.$refs.chartListWrap.$refs.listRef.scrollHeight;
  629. if(scrollTop + clientHeight >= scrollHeight-10 && this.publicHaveMove){
  630. this.chart_page++;
  631. this.getPublicList();
  632. }
  633. },300),
  634. getChartInfo() {
  635. this.getDetailHandle();
  636. },
  637. /* 获取图表详情 */
  638. getDetailHandle() {
  639. futuresInterface.chartDetail({
  640. ChartInfoId: this.select_id
  641. }).then(res => {
  642. if(res.Ret !== 200) return
  643. this.chartInfo = res.Data.ChartInfo.Source===5 ? {
  644. ...res.Data.ChartInfo,
  645. ProfitNameEn: res.Data.DataResp.ProfitNameEn,
  646. ProfitName: res.Data.DataResp.ProfitName,
  647. } : res.Data.ChartInfo;
  648. this.tableData = [res.Data.EdbInfoList[0]]
  649. this.initCommodityData(res.Data)
  650. })
  651. },
  652. /* 删除图表 */
  653. delChartHandle() {
  654. const { ChartClassifyId,ChartInfoId } = this.chartInfo;
  655. this.$confirm('删除后该图表将不能再引用,确认删除吗?', '提示', {
  656. confirmButtonText: '确定',
  657. cancelButtonText: '取消',
  658. type: 'warning',
  659. })
  660. .then(() => {
  661. this.delApi(ChartClassifyId,ChartInfoId,'del_chart');
  662. })
  663. .catch(() => {});
  664. },
  665. /* 刷新图表 */
  666. refreshHandle() {
  667. this.refreshLoading = this.$loading({
  668. lock: true,
  669. target: '.main-right',
  670. text: '刷新图表中...',
  671. spinner: 'el-icon-loading',
  672. background: 'rgba(255, 255, 255, 0.8)',
  673. });
  674. futuresInterface
  675. .refreshChart({
  676. ChartInfoId: this.chartInfo.ChartInfoId,
  677. })
  678. .then((res) => {
  679. this.refreshLoading.close();
  680. if (res.Ret === 200) {
  681. this.getDetailHandle();
  682. this.$message.success(res.Msg);
  683. }
  684. });
  685. },
  686. /* 编辑图表 */
  687. editChartHandle() {
  688. this.$router.push({
  689. path: '/addCommodityChart',
  690. query: {
  691. code: this.chartInfo.UniqueCode,
  692. scence:this.chartInfo.Source==2?'price':'profit'
  693. }
  694. })
  695. },
  696. /* 加入我的图库 */
  697. addMychartHandle(item) {
  698. this.add_chart_id = item.ChartInfoId;
  699. //已有的分类ids
  700. this.add_ids = item.MyChartClassifyId ? item.MyChartClassifyId.split(',').map(item => Number(item)) : [];
  701. this.isAddMyChart = true;
  702. },
  703. /* 加入我的图库成功 */
  704. addMySuccess(params) {
  705. this.isAddMyChart = false;
  706. /* 判断是详情还是图库列表 */
  707. if (this.selected_chartid) {
  708. this.chartInfo.IsAdd = true;
  709. this.chartInfo.MyChartId = params.MyChartInfoId;
  710. this.chartInfo.MyChartClassifyId = params.MyChartClassifyId;
  711. } else {
  712. this.chartList.forEach((item) => {
  713. if (item.ChartInfoId === this.add_chart_id) {
  714. item.IsAdd = true;
  715. item.MyChartId = params.MyChartInfoId;
  716. item.MyChartClassifyId = params.MyChartClassifyId
  717. }
  718. });
  719. }
  720. },
  721. /* 重绘右侧区域宽度 */
  722. reloadRightWid() {
  723. let total_wid = $('.data-sheet-main')[0].offsetWidth;
  724. let left = $('#left')[0].offsetWidth;
  725. let rigtWid = total_wid - left - 20 + 'px';
  726. $('#right')[0].style.width = rigtWid;
  727. },
  728. handleDblClick(data){
  729. if(!this.permissionBtn.isShowBtn('productPricePermission','goodsPrice_classifyOpt_edit')) return
  730. this.editNodeLabel(data)
  731. }
  732. },
  733. mounted() {
  734. if(this.$route.query.code) {
  735. this.getTreeData({code: this.$route.query.code,id: Number(this.$route.query.id)})
  736. } else {
  737. this.getTreeData();
  738. this.getPublicList();
  739. }
  740. window.addEventListener('resize', this.reloadRightWid);
  741. },
  742. destroyed() {
  743. window.removeEventListener('resize', this.reloadRightWid);
  744. }
  745. }
  746. </script>
  747. <style lang='scss' scoped>
  748. @import '~@/views/chartRelevance_manage/css/index.scss';
  749. </style>
  750. <style lang="scss">
  751. @import '~@/views/chartRelevance_manage/css/pub.scss';
  752. </style>