MixedTable.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. <template>
  2. <div class="table-wrapper">
  3. <template v-if="config.data.length">
  4. <table
  5. width="auto"
  6. border="0"
  7. class="table"
  8. :style="disabled ? 'width:100%' : ''"
  9. >
  10. <thead>
  11. <tr>
  12. <!-- 行头 -->
  13. <th class="th-tg sm"></th>
  14. <!-- 列头 -->
  15. <th
  16. v-for="(item, index) in columnHeader"
  17. :key="index"
  18. class="th-tg th-col"
  19. :data-cindex="item"
  20. :data-rindex="-1"
  21. @contextmenu.prevent="rightClickHandle"
  22. >
  23. {{ item }}
  24. </th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. <tr v-for="(row, index) in config.data" :key="index">
  29. <!-- 行头 -->
  30. <th
  31. class="th-tg th-row sm"
  32. @contextmenu.prevent="rightClickHandle"
  33. :data-rindex="rowHeader[index]"
  34. :data-cindex="-1"
  35. >
  36. {{ rowHeader[index] }}
  37. </th>
  38. <td
  39. v-for="(cell, cell_index) in row"
  40. :key="`${index}_${cell_index}`"
  41. :data-rindex="rowHeader[index]"
  42. :data-cindex="columnHeader[cell_index]"
  43. :data-key="cell.Uid"
  44. @click="clickCell($event, cell)"
  45. @contextmenu.prevent="rightClickHandle($event,cell)"
  46. @mouseenter="getRelationEdbInfo(cell)"
  47. >
  48. <!-- 插入单元格禁止编辑 -->
  49. <template v-if="[4,5].includes(cell.DataType) || disabled">
  50. <!-- 单元格类型5显示指标浮窗 -->
  51. <el-popover
  52. v-if="cell.DataType===5&&!disabled"
  53. placement="top-start"
  54. width="350"
  55. trigger="hover"
  56. >
  57. <ul>
  58. <li style="display:flex;margin:10px;">
  59. <label style="min-width:80px;">指标名称</label>
  60. {{cellrelationEdbInfo.EdbName}}
  61. </li>
  62. <li style="display:flex;margin:10px;">
  63. <label style="min-width:80px;">指标ID</label>
  64. {{cellrelationEdbInfo.EdbCode}}
  65. </li>
  66. </ul>
  67. <span
  68. slot="reference"
  69. :data-rindex="rowHeader[index]"
  70. :data-cindex="columnHeader[cell_index]"
  71. :data-key="cell.Uid"
  72. >{{ cell.ShowValue }}</span>
  73. </el-popover>
  74. <span
  75. :data-rindex="rowHeader[index]"
  76. :data-cindex="columnHeader[cell_index]"
  77. :data-key="cell.Uid"
  78. v-else
  79. >{{ cell.ShowValue }}</span>
  80. </template>
  81. <el-autocomplete
  82. v-else
  83. v-model="cell.ShowValue"
  84. :fetch-suggestions="searchTarget"
  85. popper-class="edb-select-popover"
  86. :data-key="cell.Uid"
  87. :data-rindex="rowHeader[index]"
  88. :data-cindex="columnHeader[cell_index]"
  89. :highlight-first-item="cell.DataType===2"
  90. @select="selectTarget($event,cell)"
  91. @click="clickCell($event, cell)"
  92. @change.native="changeVal($event, cell)"
  93. >
  94. <template slot-scope="scope">
  95. <edbDetailPopover :info="scope.item">
  96. <div slot="reference" v-if="cell.DataType===2" class="edb-item">
  97. <span class="edb-item-name text_oneLine">{{ scope.item.EdbName }}</span>
  98. <i class="el-icon-check" style="color:#0052D9;font-size:18px;"/>
  99. </div>
  100. <div slot="reference" v-else>{{ scope.item.EdbName }}</div>
  101. </edbDetailPopover>
  102. </template>
  103. </el-autocomplete>
  104. </td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. <!-- 右键菜单 -->
  109. <div class="contextMenu-wrapper" id="contextMenu-wrapper" @mouseleave="hideContextMenu">
  110. <div :class="['item',{'deletesty': menu.key==='reset'}]" v-for="menu in config.contextMenuOption" :key="menu.key" @click="handleContext(menu.key)">{{menu.label}}</div>
  111. </div>
  112. </template>
  113. <div class="nodata" v-else>
  114. <tableNoData text="暂无数据"/>
  115. </div>
  116. <!-- 选择指标 -->
  117. <selectTargetValueDia
  118. :isShow.sync="isSelectTargetValueDialog"
  119. @insert="insertSelectData"
  120. ref="selectTargetValueRef"
  121. />
  122. </div>
  123. </template>
  124. <script>
  125. import {
  126. getRowHeaderCode,
  127. getColumnHeaderCode,
  128. selectCellStyle,
  129. selectMoreCellStyle,
  130. setRelationStyle,
  131. getRightClickMenu,
  132. checkDateFormat,
  133. setFocus,
  134. findCellByKey,
  135. resetRelationStyle,
  136. resetDialogCellStyle
  137. } from "../common/customTable";
  138. import * as sheetInterface from "@/api/modules/sheetApi.js";
  139. import { dataBaseInterface } from '@/api/api.js';
  140. import md5 from '@/utils/md5.js';
  141. import selectTargetValueDia from './selectTargetValueDia.vue';
  142. export default {
  143. props: {
  144. disabled: { //是否只预览
  145. type: Boolean,
  146. default: false,
  147. }
  148. },
  149. components: { selectTargetValueDia },
  150. computed: {
  151. //列头
  152. columnHeader() {
  153. return getColumnHeaderCode(
  154. this.config.data[0] ? this.config.data[0].length : 0
  155. );
  156. },
  157. //行头
  158. rowHeader() {
  159. let total_length = this.config.data.length;
  160. // console.log(this.config.data)
  161. return getRowHeaderCode(total_length);
  162. },
  163. },
  164. data() {
  165. return {
  166. config: {
  167. data: [], //单元格类型 1日期格 2指标格 3自定义输入 4插入值 有关联的日期和指标格 5弹窗里的插入值 有关联日期格
  168. contextMenuOption: [],
  169. },
  170. selectCell: {},//选中单元格info
  171. rightClickCell: {},//右键单元格 key c r
  172. insertTargetCell: {},//选择右键插入指标的单元格 可和右键单元格不一样 key c r
  173. insertRelationArr: [],
  174. isSelectTargetValueDialog: false,
  175. cellrelationEdbInfo: {}
  176. };
  177. },
  178. mounted() {
  179. if(this.$route.path === '/addMixedSheet' && !this.$route.query.id) this.initData();
  180. },
  181. methods: {
  182. async searchTarget(query,cb) {
  183. if(!query||checkDateFormat(query)) return cb([])
  184. const { DataType,EdbInfoId } = this.selectCell;
  185. const res = DataType===2
  186. ? await dataBaseInterface.targetDetail({EdbInfoId})
  187. : await sheetInterface.searchTarget({
  188. KeyWord: query,
  189. CurrentIndex: 1,
  190. PageSize: 1000
  191. })
  192. if(res.Ret !== 200) return
  193. let arr = DataType===2 ? [res.Data] : (res.Data.List||[])
  194. cb(arr);
  195. },
  196. /* 单击 */
  197. clickCell(e, cell) {
  198. if(this.disabled) return
  199. selectCellStyle(e);
  200. this.selectCell = cell;
  201. setFocus(e);
  202. //插入值时寻找关联依赖的单元格 设置选框
  203. if([4,5].includes(cell.DataType)) {
  204. const { key } = e.target.dataset;
  205. if(!this.insertRelationArr.find(_ => _.key===key)) return
  206. let { relation_date,relation_edb } = this.insertRelationArr.find(_ => _.key===key)
  207. relation_date.key && setRelationStyle(relation_date)
  208. relation_edb.key && setRelationStyle(relation_edb)
  209. }
  210. this.isSelectTargetValueDialog&&this.$refs.selectTargetValueRef.chooseEdb(this.$refs.selectTargetValueRef.edbInfo)
  211. },
  212. /* 插入值 往左往上寻找同行同列是否有符合条件的一指标一日期 */
  213. async insertValue() {
  214. let params = this.findNearestCell();
  215. console.log(params)
  216. if(!params) {
  217. this.selectCell.DataType = 3;
  218. this.selectCell.ShowValue = '';
  219. this.selectCell.Value = '';
  220. this.selectCell.DataTime = '';
  221. this.selectCell.EdbInfoId = 0;
  222. this.$message.warning('无法在此处插入值');
  223. return
  224. }
  225. const { EdbInfoId,Date } = params
  226. const res = await sheetInterface.insertData({EdbInfoId,Date})
  227. if(res.Ret !==200) return
  228. if(!res.Data){
  229. this.selectCell.DataType = 3;
  230. this.selectCell.ShowValue = '';
  231. this.selectCell.Value = '';
  232. this.selectCell.DataTime = '';
  233. this.selectCell.EdbInfoId = 0;
  234. this.$message.warning('所选指标的所选日期无值')
  235. return
  236. }
  237. this.$message.success('插入成功')
  238. this.selectCell.DataType = 4;
  239. this.selectCell.ShowValue = res.Data;
  240. this.selectCell.Value = res.Data;
  241. this.selectCell.EdbInfoId = EdbInfoId;
  242. this.selectCell.DataTime = Date;
  243. this.setRelation(params)
  244. },
  245. // 建立插入单元格和依赖单元格关联关系
  246. setRelation(data,cellType=4) {
  247. const { insert_cell } = data;
  248. let relation_obj = {
  249. type: cellType,
  250. key: insert_cell.key,
  251. relation_date: {
  252. type: 1,
  253. key: insert_cell.relation_date
  254. },
  255. relation_edb: {
  256. type: 2,
  257. key: insert_cell.relation_edb
  258. }
  259. }
  260. let haveIndex = this.insertRelationArr.findIndex(_ => _.key===insert_cell.key);
  261. if(haveIndex===-1) {
  262. this.insertRelationArr.push(relation_obj)
  263. }else {
  264. this.insertRelationArr.splice(haveIndex,1,relation_obj)
  265. }
  266. console.log(this.insertRelationArr)
  267. },
  268. /* 向左向上找出所有格子 找出离插入单元格最近的两个符合条件的单元格 看是否满足一指标一日期的条件
  269. 不满足就无法插入值
  270. */
  271. findNearestCell() {
  272. let { rindex,cindex,key } = this.rightClickCell;
  273. let index_row = this.rowHeader.findIndex(_ => _===rindex);
  274. let index_col = this.columnHeader.findIndex(_ => _===cindex);
  275. //同行左侧所有格子
  276. let row_cell_arr = this.config.data[index_row].filter((_,cell_index) => cell_index<index_col);
  277. //同列上侧所有格子
  278. let col_cell_arr = this.config.data.filter((row,row_index) => row_index<index_row).map(row=> row[index_col]);
  279. if(!row_cell_arr.length || !col_cell_arr.length){
  280. return null
  281. }
  282. //寻找最近的符合1 2类型的两个格子
  283. let params = null;
  284. for (let i = row_cell_arr.length - 1; i >= 0; i--) {
  285. for (let j = col_cell_arr.length - 1; j >= 0; j--) {
  286. if(!params) {
  287. if((row_cell_arr[i].DataType===1&&col_cell_arr[j].DataType===2)
  288. ||(row_cell_arr[i].DataType===2&&col_cell_arr[j].DataType===1)) {
  289. params = {
  290. Date: row_cell_arr[i].DataType===1 ? row_cell_arr[i].ShowValue : col_cell_arr[j].ShowValue,
  291. EdbInfoId: row_cell_arr[i].DataType===2 ? row_cell_arr[i].EdbInfoId : col_cell_arr[j].EdbInfoId,
  292. insert_cell: {
  293. key,
  294. relation_date: row_cell_arr[i].DataType===1 ? row_cell_arr[i].Uid: col_cell_arr[j].Uid,
  295. relation_edb: row_cell_arr[i].DataType===2 ? row_cell_arr[i].Uid: col_cell_arr[j].Uid,
  296. },
  297. }
  298. break
  299. }
  300. }
  301. }
  302. }
  303. return params;
  304. },
  305. /* 选择指标 单元格类型为2 已经是指标单元格了就重置单元格 否则就视为选择指标*/
  306. selectTarget(e,cell) {
  307. const { EdbName,EdbInfoId } = e;
  308. //如果已经是指标单元格了再次点击就清空
  309. if(cell.DataType===2&&cell.EdbInfoId) {
  310. this.clearCell()
  311. }else {
  312. cell.DataType = 2;
  313. cell.DataTime = '';
  314. cell.ShowValue = EdbName;
  315. cell.Value = EdbName;
  316. cell.EdbInfoId = EdbInfoId;
  317. }
  318. this.checkCellRelation(cell)
  319. },
  320. /* 输入框失焦 */
  321. async changeVal(e, cell) {
  322. // 是日期格式 DataType为1
  323. // 否则是3
  324. const {value} = e.target;
  325. if(!value){ //无值重置单元格
  326. cell.DataType = 3;
  327. cell.ShowValue = value;
  328. cell.Value = value;
  329. cell.EdbInfoId = 0;
  330. cell.DataTime = '';
  331. }else {
  332. //指标类型不做格式处理
  333. if(cell.DataType===2) return
  334. console.log(checkDateFormat(value))
  335. if(checkDateFormat(value)) { //是日期格式
  336. cell.DataType = 1;
  337. cell.ShowValue = checkDateFormat(value);
  338. cell.Value = checkDateFormat(value);
  339. }else if(cell.EdbInfoId&&!cell.DataTime&&cell.Value===value) {//指标
  340. }else {//自定义值
  341. cell.DataType = 3;
  342. cell.ShowValue = value;
  343. cell.Value = value;
  344. cell.EdbInfoId = 0;
  345. cell.DataTime = '';
  346. }
  347. }
  348. //判断是否是有插入值的依赖单元格 更新值或重置关系
  349. this.checkCellRelation(cell)
  350. },
  351. /* 当前单元格是否和插入值有关联 无就不管 */
  352. async checkCellRelation(cell) {
  353. if(!this.insertRelationArr.length) return
  354. const key= cell.Uid;
  355. //有关联的N组数组
  356. let haveRelationArr = this.insertRelationArr.filter(_ => _.relation_date.key===key||_.relation_edb.key===key);
  357. if(!haveRelationArr.length) return
  358. //去处理每一组关联的情况
  359. haveRelationArr.forEach( async(relation) => {
  360. const { relation_date,relation_edb } = relation;
  361. if((relation_date.key === key && cell.DataType === 1) || (relation_edb.key === key && cell.DataType === 2)) { //单元格类型不变只变值仍有关联关系 更新值
  362. //刷新插入值结果
  363. let params = null;
  364. if(relation_date.key === key && cell.DataType === 1) { //修改的是依赖日期格
  365. let { EdbInfoId } = findCellByKey(this.config.data,relation.key)
  366. params = {
  367. EdbInfoId,
  368. Date: cell.ShowValue
  369. }
  370. } else if( relation_edb.key === key && cell.DataType === 2) { //修改的依赖指标格
  371. let {ShowValue} = findCellByKey(this.config.data,relation_date.key)
  372. params = {
  373. EdbInfoId: cell.EdbInfoId,
  374. Date: ShowValue
  375. }
  376. }
  377. const res = await sheetInterface.insertData(params)
  378. if(res.Ret !==200) return
  379. !res.Data && this.updateInsertCell(relation.key);
  380. res.Data && this.config.data.forEach(row => {
  381. row.forEach(cell => {
  382. if(cell.Uid === relation.key) {
  383. cell.DataType = relation.type;
  384. cell.ShowValue = res.Data;
  385. cell.Value = res.Data;
  386. cell.EdbInfoId = params.EdbInfoId;
  387. cell.DataTime = params.Date;
  388. }
  389. })
  390. })
  391. }else {
  392. // 清除插入值单元格式和关联关系
  393. this.updateInsertCell(relation.key);
  394. }
  395. })
  396. },
  397. // 清除插入值单元格式和关联关系
  398. updateInsertCell(key) {
  399. this.config.data.forEach(row => {
  400. row.forEach(cell => {
  401. if(cell.Uid === key) {
  402. cell.DataType = 3;
  403. cell.EdbInfoId = 0;
  404. cell.DataTime = '';
  405. cell.ShowValue = '';
  406. cell.Value = '';
  407. }
  408. })
  409. })
  410. let relationIndex = this.insertRelationArr.findIndex(_ => _.key===key)
  411. this.insertRelationArr.splice(relationIndex,1)
  412. },
  413. /* 右键 */
  414. rightClickHandle(e,cell) {
  415. if(this.disabled) return
  416. const { rindex,cindex,key } = e.target.dataset;
  417. this.rightClickCell = {
  418. rindex,
  419. cindex,
  420. key
  421. }
  422. this.selectCell = cell;
  423. let pos;
  424. if(rindex==='-1') { //列头处
  425. pos = 'col'
  426. }else if(cindex==='-1') { //行头
  427. pos = 'row'
  428. }else {//单元格
  429. pos = 'cell'
  430. }
  431. this.config.contextMenuOption = getRightClickMenu(pos)
  432. const dom = $('#contextMenu-wrapper')[0];
  433. dom.style.left = e.clientX-3 + 'px';
  434. dom.style.top = e.clientY-3 + 'px';
  435. ['col','row'].includes(pos) && selectMoreCellStyle(e);
  436. pos==='cell' && this.clickCell(e,cell);
  437. },
  438. /* */
  439. hideContextMenu() {
  440. const dom = $('#contextMenu-wrapper')[0];
  441. dom.style.left = '-9999px';
  442. dom.style.top = '-9999px';
  443. },
  444. /* 右键事件 */
  445. async handleContext(key) {
  446. const keyMap = {
  447. 'del': this.delColOrRow,
  448. 'insert-col-left': this.insertCol,
  449. 'insert-col-right': this.insertCol,
  450. 'insert-row-up': this.insertRow,
  451. 'insert-row-down': this.insertRow,
  452. 'insert-value': this.insertValue,
  453. 'choose-target': this.selectTargetOpen,
  454. 'reset': this.clearCell
  455. }
  456. keyMap[key] && keyMap[key](key)
  457. this.hideContextMenu()
  458. },
  459. /* 打开选择指标弹窗
  460. 打开弹窗后仍可以在页面上点击 多存一个选择指标时的信息 */
  461. selectTargetOpen() {
  462. this.insertTargetCell = this.selectCell;
  463. resetDialogCellStyle();
  464. setRelationStyle({ key:this.insertTargetCell.Uid },'td-choose-insert-target')
  465. this.isSelectTargetValueDialog = true;
  466. },
  467. /* 插入选择指标的值 */
  468. insertSelectData({ edbId,value }) {
  469. this.insertTargetCell.DataType = 5;
  470. this.insertTargetCell.ShowValue = value;
  471. this.insertTargetCell.Value = value;
  472. this.insertTargetCell.EdbInfoId = edbId;
  473. this.insertTargetCell.DataTime = this.selectCell.ShowValue;
  474. this.$message.success('插入成功')
  475. //建立新的关联关系
  476. let relation = {
  477. insert_cell: {
  478. key: this.insertTargetCell.Uid,
  479. relation_date: this.selectCell.Uid,
  480. relation_edb: '',
  481. }
  482. }
  483. this.setRelation(relation,5);
  484. },
  485. /* 清除单元格内容 格式 关联关系 */
  486. clearCell() {
  487. if([4,5].includes(this.selectCell.DataType)) resetRelationStyle();
  488. this.selectCell.DataType = 3;
  489. this.selectCell.ShowValue = '';
  490. this.selectCell.Value = '';
  491. this.selectCell.DataTime = '';
  492. this.selectCell.EdbInfoId = 0;
  493. this.checkCellRelation(this.selectCell)
  494. },
  495. /* 删除行列 */
  496. delColOrRow() {
  497. let { rindex,cindex } = this.rightClickCell;
  498. if(rindex==='-1') { //删除列
  499. console.log('删除列',cindex)
  500. if(this.columnHeader.length === 1) return this.$message.warning('请至少保留一列')
  501. let index = this.columnHeader.findIndex(_ => _ === cindex);
  502. //删除时清除关系
  503. if(this.insertRelationArr.length) {
  504. let delCellIds = this.config.data.map(row => row[index].Uid);
  505. this.clearRelationInsertCell(delCellIds);
  506. }
  507. this.config.data.forEach(row => {
  508. row.splice(index,1)
  509. })
  510. }else if(cindex === '-1') { //删除行
  511. console.log('删除行',rindex)
  512. if(this.rowHeader.length === 1) return this.$message.warning('请至少保留一行')
  513. let index = this.rowHeader.findIndex(_ => _ === rindex)
  514. if(this.insertRelationArr.length) {
  515. //删除时清除关系
  516. let delCellIds = this.config.data[index].map(cell => cell.Uid);
  517. this.clearRelationInsertCell(delCellIds);
  518. }
  519. this.config.data.splice(index,1)
  520. }
  521. // console.log(this.insertRelationArr)
  522. },
  523. /* 删除时清除关联关系 和删除单元格有关联的插入值单元格和 */
  524. clearRelationInsertCell(delCellIds) {
  525. //清除关联插入值得单元格
  526. let haveRelationArr = this.insertRelationArr.filter(_ => delCellIds.includes(_.relation_date.key)||delCellIds.includes(_.relation_edb.key));
  527. // console.log(haveRelationArr)
  528. haveRelationArr.forEach(relation => {
  529. !delCellIds.includes(relation)&&this.updateInsertCell(relation.key);
  530. })
  531. this.insertRelationArr = this.insertRelationArr.filter(_ => !delCellIds.includes(_.key)&&!delCellIds.includes(_.relation_date.key)&&!delCellIds.includes(_.relation_edb.key))
  532. },
  533. /* 插入列 */
  534. insertCol(key) {
  535. let { cindex } = this.rightClickCell;
  536. let index = this.columnHeader.findIndex(_ => _ === cindex);
  537. this.config.data.forEach((row,rindex) => {
  538. row.splice(key==='insert-col-left'?index:index+1,0,{
  539. ShowValue: "",
  540. Value: "",
  541. DataType: 3,
  542. DataTime: "",
  543. EdbInfoId: 0,
  544. Uid: md5.hex_md5(`${new Date().getTime()}${rindex}`)
  545. })
  546. })
  547. },
  548. /* 插入行 */
  549. insertRow(key) {
  550. let { rindex } = this.rightClickCell;
  551. let index = this.rowHeader.findIndex(_ => _ === rindex)
  552. let row = new Array(this.columnHeader.length).fill("").map((_,cindex) => ({
  553. ShowValue: "",
  554. Value: "",
  555. DataType: 3,
  556. DataTime: "",
  557. EdbInfoId: 0,
  558. Uid: md5.hex_md5(`${new Date().getTime()}${cindex}`)
  559. }));
  560. this.config.data.splice( key==='insert-row-up'?index:index+1,0,row)
  561. },
  562. /* 单元格类型5 浮到上面展示指标信息浮窗 */
  563. async getRelationEdbInfo({EdbInfoId,DataType}) {
  564. if(DataType!==5||this.disabled) return
  565. const res = await dataBaseInterface.targetDetail({EdbInfoId})
  566. if(res.Ret !== 200) return
  567. this.cellrelationEdbInfo = res.Data;
  568. },
  569. /* 初始化8行5列 */
  570. initData(initData=null) {
  571. if(initData) {
  572. const { CellRelation,Data } = initData;
  573. this.config.data = Data;
  574. this.insertRelationArr = JSON.parse(CellRelation);
  575. }else {
  576. this.config.data = new Array(8).fill("").map((_,_rindex) => {
  577. return new Array(5).fill("").map((cell,_cindex) => ({
  578. ShowValue: "",
  579. Value: "",
  580. DataType: 3,
  581. DataTime: "",
  582. EdbInfoId:0,
  583. Uid: md5.hex_md5(`${new Date().getTime()}${_rindex}${_cindex}`)
  584. }));
  585. });
  586. }
  587. },
  588. },
  589. };
  590. </script>
  591. <style scoped lang="scss">
  592. .nodata {
  593. text-align: center;
  594. font-size: 16px;
  595. color: #666;
  596. padding: 100px 0;
  597. }
  598. .table-wrapper {
  599. width: 100%;
  600. overflow: auto;
  601. .table td,th {
  602. width: 104px;
  603. min-width: 104px;
  604. height: 35px;
  605. background: #fff;
  606. text-align: center;
  607. word-break: break-all;
  608. border: 1px solid #dcdfe6;
  609. overflow: hidden;
  610. text-overflow: ellipsis;
  611. position: relative;
  612. color: #606266;
  613. &.td-chose::after {
  614. position: absolute;
  615. top: 0;
  616. left: 0;
  617. right: 0;
  618. bottom: 0;
  619. content: "";
  620. display: block;
  621. outline: 0;
  622. border: 2px solid #0033ff;
  623. box-shadow: 0 0 5px rgba(73, 177, 249, 0.5);
  624. }
  625. &.td-relation::after {
  626. position: absolute;
  627. top: 0;
  628. left: 0;
  629. right: 0;
  630. bottom: 0;
  631. content: "";
  632. display: block;
  633. outline: 0;
  634. border: 2px dashed #0033ff;
  635. box-shadow: 0 0 5px rgba(73, 177, 249, 0.5);
  636. }
  637. &.td-col-select::after {
  638. position: absolute;
  639. top: 0;
  640. left: 0;
  641. right: 0;
  642. bottom: 0;
  643. content: "";
  644. display: block;
  645. outline: 0;
  646. border: 1px solid rgb(24, 173, 24);
  647. border-bottom: none;
  648. border-top: none;
  649. }
  650. &.td-row-select::after {
  651. position: absolute;
  652. top: 0;
  653. left: 0;
  654. right: 0;
  655. bottom: 0;
  656. content: "";
  657. display: block;
  658. outline: 0;
  659. border: 1px solid rgb(24, 173, 24);
  660. border-left: none;
  661. border-right: none;
  662. }
  663. &.td-choose-insert-target::after {
  664. position: absolute;
  665. top: 0;
  666. left: 0;
  667. right: 0;
  668. bottom: 0;
  669. content: "";
  670. display: block;
  671. outline: 0;
  672. border: 2px dashed orange;
  673. box-shadow: 0 0 5px rgba(73, 177, 249, 0.5);
  674. }
  675. }
  676. .th-tg {
  677. background: #ebeef5;
  678. &:hover {
  679. cursor: pointer;
  680. background: #ddd;
  681. /* border: 2px solid #409eff; */
  682. }
  683. &.sm {
  684. width: 36px;
  685. min-width: 36px;
  686. max-width: 36px;
  687. }
  688. }
  689. //整行选中
  690. tr {
  691. position: relative;
  692. &.choose-all::after {
  693. position: absolute;
  694. top: 0;
  695. left: 0;
  696. right: 0;
  697. bottom: 0;
  698. content: "";
  699. display: block;
  700. outline: 0;
  701. border: 2px solid #5897fb;
  702. box-shadow: 0 0 5px rgba(73, 177, 249, 0.5);
  703. }
  704. }
  705. .contextMenu-wrapper {
  706. position: fixed;
  707. z-index: 99;
  708. top: -9999px;
  709. left: -9999px;
  710. background: #fff;
  711. padding: 10px 0;
  712. /* border: 1px solid #999; */
  713. box-shadow: 0 1px 4px #999;
  714. .item {
  715. padding: 10px 25px;
  716. cursor: pointer;
  717. &:hover {
  718. background-color: #f5f7fa;
  719. }
  720. }
  721. }
  722. }
  723. </style>
  724. <style lang="scss">
  725. .table-wrapper {
  726. td {
  727. .el-input__inner {
  728. border: none;
  729. outline: none;
  730. text-align: center;
  731. height: 34px;
  732. line-height: 34px;
  733. }
  734. }
  735. .el-input.is-disabled .el-input__inner {
  736. background-color: #fff;
  737. }
  738. }
  739. .edb-select-popover {
  740. width: 300px !important;
  741. .edb-item {
  742. display: flex;
  743. justify-content: space-between;
  744. align-items: center;
  745. .edb-item-name {
  746. max-width: 260px;
  747. }
  748. }
  749. }
  750. </style>