tables.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. <template>
  2. <el-table
  3. :data="emTableList.tableData"
  4. :key="emTableList.tableName"
  5. v-loading="emTableList.loading"
  6. :lazy="
  7. emTableList.options.hasOwnProperty('lazy')
  8. ? emTableList.options.lazy
  9. : true
  10. "
  11. :load="loadChildren"
  12. :tree-props="emTableList.treeProps"
  13. :stripe="emTableList.stripe === false ? false : true"
  14. style="width: 100%"
  15. :row-key="emTableList.rowKey"
  16. :default-sort="{prop: 'totalQty', order: 'descending'}"
  17. ref="multipleTable"
  18. @sort-change="sortReloadData"
  19. @selection-change="handleSelectionChange"
  20. :cell-style="emTableList.bodyCellStyle"
  21. :header-cell-style="emTableList.headerCellStyle"
  22. :row-class-name="tableRowClassName"
  23. :border="emTableList.border === false ? false : true"
  24. @filter-change="filterColHandler"
  25. >
  26. <el-table-column v-if="emTableList.isMultiple" type="selection" :fixed="true" align="center"></el-table-column>
  27. <el-table-column
  28. v-for="(item, index) in emTableList.showColumns"
  29. v-if="isShow(item) && item.stype !== 'checkbox'"
  30. :key="index"
  31. :header-align="item.headerAlign ? sub.headerAlign : 'center'"
  32. :prop="item.field"
  33. :width="item.width ? item.width : 'auto'"
  34. :align="item.align ? item.align : 'center'"
  35. :sort-orders="['descending','ascending',null]"
  36. :sortable="item.sort ? item.sort : false"
  37. :fixed="item.fixed ? item.fixed : false"
  38. :show-overflow-tooltip="item.tooltip === false ? false : true"
  39. :filters="tcpFilters(item)"
  40. :column-key="item.field ? item.field : ''"
  41. :filter-multiple="item.filterMultiple ? item.filterMultiple : false"
  42. :formatter="item.formatter ? formatter : formatterDef"
  43. :class-name="item.className"
  44. >
  45. <!--list属性-->
  46. <template v-if="item.stype == 'list'">
  47. <el-table-column
  48. v-for="(sub, subIndex) in item.sub"
  49. :key="subIndex"
  50. :header-align="sub.headerAlign ? sub.headerAlign : 'center'"
  51. :prop="sub.field"
  52. :label="sub.name"
  53. :width="sub.width ? sub.width : ''"
  54. :align="sub.align ? sub.align : 'center'"
  55. :sortable="sub.sort ? sub.sort : false"
  56. :fixed="sub.fixed ? sub.fixed : false"
  57. :show-overflow-tooltip="sub.tooltip === false ? false : true"
  58. :formatter="sub.formatter ? formatter : formatterDef"
  59. :filters="item.filters"
  60. :column-key="item.field"
  61. :filter-multiple="item.filterMultiple ? item.filterMultiple : false"
  62. >
  63. <template slot-scope="scope" >
  64. <!--mapping属性-->
  65. <span v-if="sub.stype == 'mapping'">{{
  66. mapping(scope.row, sub)
  67. }}</span>
  68. <span v-else-if="sub.stype === 'custom'">
  69. <component :is="sub.cellComp" :item="sub" :rowData="scope.row" @eventBus="cellCompEvent(scope.row,sub)"/>
  70. </span>
  71. <span v-else>{{ scope.row[sub.field] |nullMap }}</span>
  72. </template>
  73. </el-table-column>
  74. </template>
  75. <template slot="header">
  76. <ul class="table-expand-list" v-if="item.expand">
  77. <li
  78. v-for="(expandItem, expandIndex) of scope.row[item.expand.list]"
  79. :key="expandIndex"
  80. >
  81. <div class="name" :style="item.expand.nameStyle">
  82. {{ expandItem[item.expand.key] }}:
  83. </div>
  84. <div class="value" :style="item.expand.valueStyle">
  85. {{ expandParseValue(expandItem, item.expand) }}
  86. </div>
  87. </li>
  88. </ul>
  89. <el-tooltip
  90. v-if="item.hasOwnProperty('note') && item.note"
  91. class="item"
  92. effect="dark"
  93. :content="item.note"
  94. placement="top"
  95. >
  96. <span class="icon-name icon-info"
  97. ><i class="el-icon-info"></i
  98. ></span>
  99. </el-tooltip>
  100. <el-button
  101. v-if="item.hasOwnProperty('explain') && item.explain"
  102. icon="el-icon-info"
  103. style="padding: 0; margin-right: 4px"
  104. circle
  105. @click="emTableList.tableBtnEvent(item, { type: item.explain })"
  106. ></el-button>
  107. <span class="icon-name icon-info-name">{{ item.name }}</span>
  108. </template>
  109. <template slot-scope="scope" >
  110. <!--按钮-->
  111. <template v-if="item.stype === 'opt'">
  112. <el-button
  113. v-for="(opt, optIndex) in tableButtonList(item, scope)"
  114. :key="optIndex"
  115. :type="opt.bType ? opt.bType : 'text'"
  116. :style="opt.style ? opt.style : ''"
  117. :icon="opt.icon ? opt.icon : ''"
  118. :size="opt.size ? opt.size : 'small'"
  119. :plain="opt.shape === 'plain' ? true : false"
  120. :round="opt.shape === 'round' ? true : false"
  121. :circle="opt.shape === 'circle' ? true : false"
  122. :disabled="opt.hasOwnProperty('disabled') ? opt.disabled : false"
  123. @click="optCellData(scope.row, opt)"
  124. v-shortcutKeys="{key:opt.type ==='detail'?'d':''}"
  125. >
  126. {{ opt.name }}
  127. </el-button>
  128. </template>
  129. <!-- <span v-else-if="item.stype === 'slot'">
  130. <slot :name="item.slot" :item="item" :rowData="scope.row"/>
  131. </span> -->
  132. <span v-else-if="item.stype === 'custom'">
  133. <component :is="item.cellComp" :item="item" :rowData="scope.row" @eventBus="cellCompEvent(scope.row,item,$event)"/>
  134. </span>
  135. <span v-else-if="item.stype === 'select'">
  136. <el-select
  137. v-model="scope.row[item.field]"
  138. >
  139. <el-option v-for="(o,i) in emTableList.select_list[item[item.stype].obj]" :key="i" :label="o.label" :value="o.value">
  140. {{ o.label }}</el-option>
  141. </el-select>
  142. </span>
  143. <!--tag标签-->
  144. <span v-else-if="item.stype === 'tag'">
  145. <el-popover
  146. v-if="item.tooltip === false"
  147. placement="top"
  148. style="max-width: 500px"
  149. trigger="hover"
  150. >
  151. <template v-for="(tag, index) in item.tags">
  152. <el-tag
  153. :key="index"
  154. v-if="scope.row[item.field] == tag.value"
  155. :type="tag.type"
  156. :effect="tag.effect"
  157. disable-transitions
  158. :closable="
  159. item.hasOwnProperty('closable')
  160. ? item.closable
  161. : item.action && item.action.url
  162. ? true
  163. : false
  164. "
  165. @close="handleTagListClose(item, scope.row, tag)"
  166. >{{ tag.label }}</el-tag
  167. >
  168. </template>
  169. <!--触发tooltip信息-->
  170. <span slot="reference">
  171. <template v-for="(tag, index) in item.tags">
  172. <el-tag
  173. :key="index"
  174. v-if="scope.row[item.field] == tag.value"
  175. :type="tag.type"
  176. :effect="tag.effect"
  177. disable-transitions
  178. >{{ tag.label }}</el-tag
  179. >
  180. </template>
  181. </span>
  182. </el-popover>
  183. <span v-else
  184. >
  185. <template v-for="(tag, index) in item.tags">
  186. <el-tag
  187. :key="index"
  188. v-if="scope.row[item.field] == tag.value"
  189. :type="tag.type"
  190. :effect="tag.effect"
  191. disable-transitions
  192. >{{ tag.label }}<br /></el-tag
  193. >
  194. </template>
  195. </span>
  196. </span>
  197. <!--tag标签list-->
  198. <span v-else-if="item.stype === 'list-tag'">
  199. <el-popover
  200. v-if="item.tooltip === false"
  201. placement="top"
  202. style="max-width: 500px"
  203. trigger="hover"
  204. >
  205. <span
  206. v-if="
  207. scope.row[item.field] &&
  208. typeof scope.row[item.field] === 'string'
  209. "
  210. >
  211. <el-tag
  212. style="margin: 1px"
  213. v-for="(tag, index) in scope.row[item.field].split(',')"
  214. :key="index"
  215. disable-transitions
  216. :closable="
  217. item.hasOwnProperty('closable')
  218. ? item.closable
  219. : item.action && item.action.url
  220. ? true
  221. : false
  222. "
  223. @close="handleTagListClose(item, scope.row, tag)"
  224. >{{ tag }}</el-tag
  225. >
  226. </span>
  227. <span v-else
  228. ><el-tag
  229. style="margin: 1px"
  230. v-for="(tag, index) in scope.row[item.field]"
  231. :key="index"
  232. disable-transitions
  233. :closable="
  234. item.hasOwnProperty('closable')
  235. ? item.closable
  236. : item.action && item.action.url
  237. ? true
  238. : false
  239. "
  240. @close="handleTagListClose(item, scope.row, tag)"
  241. >{{
  242. item.action && item.action.name
  243. ? tag[item.action.name]
  244. : tag
  245. }}</el-tag
  246. ></span
  247. >
  248. <!--触发tooltip信息-->
  249. <span
  250. slot="reference"
  251. v-if="
  252. scope.row[item.field] &&
  253. typeof scope.row[item.field] === 'string'
  254. "
  255. >
  256. <el-tag
  257. style="margin: 1px"
  258. v-for="(tag, index) in scope.row[item.field].split(',')"
  259. :key="index"
  260. disable-transitions
  261. >{{ tag }}</el-tag
  262. >
  263. </span>
  264. <span slot="reference" v-else
  265. ><el-tag
  266. style="margin: 1px"
  267. v-for="(tag, index) in scope.row[item.field]"
  268. :key="index"
  269. disable-transitions
  270. >{{
  271. item.action && item.action.name
  272. ? tag[item.action.name]
  273. : tag
  274. }}</el-tag
  275. ></span
  276. >
  277. </el-popover>
  278. <span v-else>
  279. <span
  280. slot="reference"
  281. v-if="
  282. scope.row[item.field] &&
  283. typeof scope.row[item.field] === 'string'
  284. "
  285. >
  286. <el-tag
  287. style="margin: 1px"
  288. v-for="(tag, index) in scope.row[item.field].split(',')"
  289. :key="index"
  290. disable-transitions
  291. >{{ tag }}<br
  292. /></el-tag>
  293. </span>
  294. <span slot="reference" v-else
  295. ><el-tag
  296. style="margin: 1px"
  297. v-for="(tag, index) in scope.row[item.field]"
  298. :key="index"
  299. disable-transitions
  300. >{{
  301. item.action && item.action.name
  302. ? tag[item.action.name]
  303. : tag
  304. }}<br /></el-tag
  305. ></span>
  306. </span>
  307. </span>
  308. <!--link属性-->
  309. <span v-else-if="item.stype === 'link'">
  310. <el-link
  311. type="primary"
  312. @click="tableContentCellData(scope.row, item)"
  313. :underline="false"
  314. >{{ scope.row[item.field] }}</el-link
  315. >
  316. </span>
  317. <!--link-value属性-->
  318. <span v-else-if="item.stype === 'link-value'">
  319. <el-link
  320. type="primary"
  321. @click="tableContentCellData(scope.row, item)"
  322. v-if="scope.row[item.field] == item.value"
  323. :underline="false"
  324. >{{ item.label }}</el-link
  325. >
  326. <span v-else>{{
  327. scope.row[item.field] ? scope.row[item.field] : "-"
  328. }}</span>
  329. </span>
  330. <!--link-status属性-->
  331. <span v-else-if="item.stype === 'link-status'">
  332. <template v-for="(objItem, objIndex) in item.obj">
  333. <span
  334. :key="objIndex"
  335. v-if="scope.row[item.field] == objItem.value"
  336. >
  337. <el-link
  338. v-if="
  339. Array.isArray(item.value) &&
  340. item.value.includes(scope.row[item.field])
  341. "
  342. type="primary"
  343. @click="tableContentCellData(scope.row, item)"
  344. :underline="false"
  345. >{{ objItem.label ? objItem.label : "-" }}</el-link
  346. >
  347. <span v-else>{{ objItem.label ? objItem.label : "-" }}</span>
  348. </span>
  349. </template>
  350. </span>
  351. <!--switch属性-->
  352. <span v-else-if="item.stype == 'switch'">
  353. <el-switch
  354. v-model="scope.row[item.field]"
  355. :width="getPropValue(item, 'width')"
  356. :inactive-value="getPropValue(item, '00')"
  357. :inactive-text="getPropValue(item, '01')"
  358. :inactive-color="getPropValue(item, '02')"
  359. :active-value="getPropValue(item, '10')"
  360. :active-text="getPropValue(item, '11')"
  361. :active-color="getPropValue(item, '12')"
  362. :disabled="getPropValue(item, 'disabled', scope)"
  363. @change="switchChange(scope.row, item)"
  364. ></el-switch>
  365. </span>
  366. <!--image图片-->
  367. <span v-else-if="item.stype == 'image'">
  368. <span
  369. v-if="
  370. Object.prototype.toString.call(scope.row[item.field]) ===
  371. '[object Array]'
  372. "
  373. >
  374. <img
  375. v-for="(it, itIndex) in scope.row[item.field]"
  376. :key="itIndex"
  377. :src="
  378. tableImageURL(
  379. item,
  380. it[item.imageUrl] ? it[item.imageUrl] : it.url
  381. )
  382. "
  383. :style="
  384. item.tStyle ? item.tStyle : 'min-width: 50px; height: 20px;'
  385. "
  386. />
  387. </span>
  388. <img
  389. v-else
  390. :src="tableImageURL(item, scope.row[item.field])"
  391. :style="
  392. item.tStyle ? item.tStyle : 'min-width: 50px; height: 20px;'
  393. "
  394. />
  395. </span>
  396. <!--input属性-->
  397. <span v-else-if="item.stype == 'input'">
  398. <el-form
  399. v-if="columnShowStatus(item, scope)"
  400. class="table-input-form"
  401. :model="scope.row"
  402. size="small"
  403. >
  404. <div v-if="item.inputShow" class="input-label is-input">
  405. <nt-input
  406. :inputItem="item"
  407. :rowData="scope.row"
  408. :inputType="'table'"
  409. :selectList="emTableList.select_list"
  410. :axios="emTableList.axios"
  411. :queryURL="emTableList.queryURL"
  412. :responseSuccess="emTableList.responseSuccess"
  413. :publicParams="emTableList._publicParams"
  414. @onInputBlur="() => onInputBlur(scope.row, item)"
  415. ></nt-input>
  416. </div>
  417. <div v-else>
  418. <div v-if="scope.row.isInput" class="input-label is-input">
  419. <nt-input
  420. :inputItem="item"
  421. :rowData="scope.row"
  422. :inputType="'table'"
  423. :selectList="emTableList.select_list"
  424. :axios="emTableList.axios"
  425. :queryURL="emTableList.queryURL"
  426. :responseSuccess="emTableList.responseSuccess"
  427. :publicParams="emTableList._publicParams"
  428. ></nt-input>
  429. <i
  430. class="el-icon-circle-check"
  431. @click.stop="submitInputEvent(scope.row, item)"
  432. ></i>
  433. </div>
  434. <div
  435. v-else
  436. class="input-label"
  437. @click="cellInputEvent(scope.row)"
  438. >
  439. {{ scope.row[item.field] }} <i class="el-icon-edit"></i>
  440. </div>
  441. </div>
  442. </el-form>
  443. <span v-else>{{ scope.row[item.field] }}</span>
  444. </span>
  445. <!--fields属性-->
  446. <span v-else-if="item.stype == 'fields'">
  447. <span
  448. v-for="(currField, currIndex) in item.fieldList"
  449. :key="currIndex"
  450. ><span v-if="currIndex > 0">{{
  451. item.sign ? item.sign : " / "
  452. }}</span
  453. >{{ scope.row[currField] }}</span
  454. >
  455. </span>
  456. <!--mapping属性-->
  457. <span v-else-if="item.stype == 'mapping'">{{
  458. mapping(scope.row, item)
  459. }}</span>
  460. <!--rate属性-->
  461. <span v-else-if="item.stype == 'rate'">
  462. <el-rate
  463. v-model="scope.row[item.field]"
  464. :max="item.max ? item.max : 5"
  465. :disabled="item.isDisabled ? item.isDisabled : false"
  466. :allow-half="item.half ? item.half : false"
  467. :show-score="item.score ? item.score : false"
  468. :text-color="item.color ? item.color : '#1F2D3D'"
  469. score-template="{value}"
  470. ></el-rate>
  471. </span>
  472. <!--value属性-->
  473. <span v-else-if="item.stype == 'value'">{{ item.value }}</span>
  474. <!--format属性-->
  475. <span v-else-if="item.stype == 'format'">{{
  476. scope.row[item.field] | vueFiltersInit(item, scope)
  477. }}</span>
  478. <!--v-html属性-->
  479. <span
  480. v-else-if="item.stype == 'v-html'"
  481. v-html="scope.row[item.field]"
  482. ></span>
  483. <!--text-style属性-->
  484. <span v-else-if="item.stype == 'text-style'">
  485. <span
  486. :style="
  487. Object.prototype.toString.call(item.classValueName) ===
  488. '[object Function]'
  489. ? item.classValueName(scope.row, item.field)
  490. : item.classValueName
  491. "
  492. >{{ scope.row[item.field] }}</span
  493. >
  494. </span>
  495. <!--formatter-style属性-->
  496. <span
  497. v-else-if="item.stype == 'formatter-style'"
  498. v-html="formatterStyle(scope.row, item)"
  499. ></span>
  500. <span v-else>{{ scope.row[item.field] | nullMap}}</span>
  501. </template>
  502. </el-table-column>
  503. </el-table>
  504. </template><script>
  505. // import {vueFiltersInit} from '@/utils/filters'
  506. import {
  507. formatterSelf,
  508. formatterDefault,
  509. tableListUpdateRowEvent,
  510. unitTreeChildList,
  511. selectListToValue,
  512. unitTableFiltersNode,
  513. } from "./tool-table";
  514. import {
  515. isTypeof,
  516. checkAuthButtonList,
  517. isHttpHeaderURL,
  518. nullView
  519. } from "@/components/thrid/em-element-ui/src/tools/utils";
  520. import NtInput from "../../input";
  521. import bus from "@/components/thrid/em-element-ui/src/tools/eventBus";
  522. export default {
  523. name: "EmTables",
  524. components: { NtInput },
  525. props: {
  526. emTableList: {
  527. type: Object,
  528. default: () => {},
  529. },
  530. listType: {
  531. type: Array,
  532. default: [],
  533. },
  534. },
  535. data() {
  536. return {
  537. filtersList: {},
  538. isMultipleTables: this.listType.length > 1,
  539. };
  540. },
  541. watch: {},
  542. created: function () {
  543. // unitTableFiltersNode(this);
  544. },
  545. filters: {
  546. nullMap:nullView
  547. },
  548. computed: {
  549. defaultSort(){
  550. const defsort = this.showColumns.find(f=>typeof(f.sort) === 'string')
  551. return defsort && {prop: defsort.field, order: defsort.sort}
  552. },
  553. // 第一个 显示的 && 复选框列
  554. checkboxItem() {
  555. return this.emTableList.showColumns.find(f=> {
  556. return this.isShow(f) && f.stype === 'checkbox'
  557. })
  558. },
  559. // 所有显示的&& 非复选框列
  560. showColumns() {
  561. return this.emTableList.showColumns.filter(f=> {
  562. return this.isShow(f) && f.stype !== 'checkbox'
  563. })
  564. }
  565. },
  566. mounted() {
  567. if (this.isMultipleTables) {
  568. // 监听兄弟组件选中值变化
  569. bus.$on("checkedEventCardToTable", (data) => {
  570. data.forEach((item) => {
  571. if (item.hasOwnProperty("cardChecked") && item.cardChecked) {
  572. this.$refs.multipleTable.toggleRowSelection(item, true);
  573. } else {
  574. this.$refs.multipleTable.toggleRowSelection(item, false);
  575. }
  576. });
  577. });
  578. }
  579. },
  580. // filters:{
  581. // vueFiltersInit
  582. // },
  583. methods: {
  584. /** 自定义组件事件总线
  585. * 将传入的参数赋值给item.ext
  586. */
  587. cellCompEvent(row, item,ext) {
  588. item.ext = ext
  589. this.emTableList.tableBtnEvent(row, item);
  590. },
  591. // 获取表格列-filters属性
  592. tcpFilters(item) {
  593. let rv = undefined
  594. if(item.filters) {
  595. if (item.filters.push) {
  596. rv = item.filters
  597. }
  598. if (item.filters.obj) {
  599. const sl = this.emTableList.select_list[item.filters.obj]
  600. if (sl) {
  601. rv = sl.map(m=>{
  602. return {
  603. text:m.label,
  604. value:m.value
  605. }
  606. })
  607. }
  608. }
  609. }
  610. return rv
  611. },
  612. // 数据字段映射
  613. mapping(row, item) {
  614. let rv = ''
  615. if (typeof item.mapping === 'string') {
  616. rv = row[item.mapping]
  617. }
  618. if (typeof item.mapping === 'function') {
  619. rv = item.mapping(row)
  620. }
  621. if (typeof item.mapping === 'object') {
  622. // 存在select_list名称,从select_list 映射
  623. if (item.mapping.obj) {
  624. // 当前下拉数组
  625. const curs = this.emTableList.select_list[item.mapping.obj]
  626. // 存在select集合
  627. if (curs) {
  628. // 通过字段值获取 对应label
  629. const cursi = curs.find(f=>f.value == row[item.field])
  630. if(cursi) {
  631. rv = cursi.label
  632. }
  633. }
  634. }
  635. }
  636. return nullView(rv)
  637. },
  638. // 获取组件属性值
  639. getPropValue(item, type, scope) {
  640. let rv = null
  641. // switch 子属性的映射信息
  642. const maps = {
  643. switch : {
  644. // 关闭值
  645. '00': {
  646. pk:'inValue',
  647. def:0
  648. },
  649. // 关闭文案
  650. '01': {
  651. pk:'inText',
  652. def:'关闭'
  653. },
  654. // 关闭颜色
  655. '02': {
  656. pk:'inColor',
  657. def:'#aaaaaa'
  658. },
  659. // 打开值
  660. '10': {
  661. pk:'aValue',
  662. def:1
  663. },
  664. // 打开文案
  665. '11': {
  666. pk:'aText',
  667. def:'打开'
  668. },
  669. // 打开颜色
  670. '12': {
  671. pk:'aColor',
  672. def:'#13ce66'
  673. },
  674. // 宽度
  675. 'width': {
  676. pk:'width',
  677. def:50
  678. },
  679. // 禁用
  680. 'disabled': {
  681. pk:'disabled',
  682. def: false
  683. }
  684. }
  685. }
  686. // 获取stype类型对应的映射信息
  687. const curTypeMap = maps[item.stype]
  688. if(!curTypeMap) {
  689. return rv
  690. }
  691. // 获取具体的属性映射信息
  692. const curAttrMap = curTypeMap[type]
  693. if(curAttrMap) {
  694. // stype对应的类型的属性配置信息组
  695. const curTypeConfig = item[item.stype]
  696. // 存在具体属性配置
  697. if(curTypeConfig && curTypeConfig.hasOwnProperty(curAttrMap.pk)) {
  698. const cv = curTypeConfig[curAttrMap.pk]
  699. if(typeof cv === 'function' && scope) {
  700. rv = cv(scope)
  701. } else {
  702. rv = cv
  703. }
  704. // 不存在
  705. } else {
  706. rv = curAttrMap.def
  707. // // 取item中的属性信息
  708. // if(item.hasOwnProperty(curAttrMap.pk)) {
  709. // rv = item[curAttrMap.pk]
  710. // }else {// 都取不到取默认值
  711. // rv = curAttrMap.def
  712. // }
  713. }
  714. }
  715. return rv
  716. },
  717. // 改变行的颜色
  718. tableRowClassName({ row, rowIndex }) {
  719. if (isTypeof(this.emTableList.rowClassName) === "function") {
  720. return this.emTableList.rowClassName(row, rowIndex);
  721. } else {
  722. return this.emTableList.rowClassName;
  723. }
  724. },
  725. expandParseValue(row, item) {
  726. const value = item.hasOwnProperty("value")
  727. ? row.hasOwnProperty(item.value)
  728. ? row[item.value] === "null" || row[item.value] === null
  729. ? "-"
  730. : row[item.value]
  731. : "-"
  732. : "-";
  733. let resultValue = value;
  734. if (item.hasOwnProperty("obj")) {
  735. if (Array.isArray(this.emTableList.select_list[item.obj])) {
  736. this.emTableList.select_list[item.obj].forEach((node) => {
  737. if (node.value == value) {
  738. resultValue = node.label;
  739. }
  740. });
  741. }
  742. }
  743. return resultValue;
  744. },
  745. isShow(item) {
  746. if (item.hasOwnProperty("hide")) {
  747. if (isTypeof(item.hide) === "function") {
  748. const hideStatus = item.hide();
  749. return !hideStatus;
  750. } else {
  751. return !item.hide;
  752. }
  753. } else {
  754. return true;
  755. }
  756. },
  757. // 是否显示stype的组件,false显示文本
  758. columnShowStatus(item, scope) {
  759. let status = item.hasOwnProperty("iShowStatus")
  760. ? isTypeof(item.iShowStatus) === "function"
  761. ? item.iShowStatus(scope.row)
  762. : item.iShowStatus
  763. : true;
  764. return status;
  765. },
  766. // 返回有权限的操作事件
  767. tableButtonList(item, scope) {
  768. let buttons =
  769. isTypeof(item.list) === "array"
  770. ? item.list
  771. : isTypeof(item.list) === "function"
  772. ? item.list(scope)
  773. : [];
  774. if (buttons && buttons.length > 0) {
  775. return checkAuthButtonList(buttons, this.emTableList.authButtonList);
  776. } else {
  777. return [];
  778. }
  779. },
  780. optCellData(row, option) {
  781. // 操作后改变该行的背景颜色
  782. if (option.bgcolor) {
  783. if (row.hasOwnProperty("optCellSelfBgcolor")) {
  784. row.optCellSelfBgcolor = option.bgcolor;
  785. } else {
  786. this.$set(row, "optCellSelfBgcolor", option.bgcolor);
  787. }
  788. }
  789. this.emTableList.tableBtnEvent(row, option);
  790. },
  791. tableContentCellData(row, item) {
  792. let obj = Object.create(null);
  793. obj = Object.assign({}, item);
  794. obj.type = item.field;
  795. this.optCellData(row, obj);
  796. },
  797. formatterStyle(row, item) {
  798. if (item.formatter) {
  799. return selectListToValue(this, item.formatter, row[item.field], true);
  800. } else {
  801. return "";
  802. }
  803. },
  804. //格式化
  805. formatter(row, column, cellValue, index) {
  806. return formatterSelf(this, row, column, cellValue, index);
  807. },
  808. // table图片地址拼接
  809. tableImageURL(item, url) {
  810. if (isHttpHeaderURL(url)) {
  811. return url;
  812. } else {
  813. return item.fileHost + (item.path || "") + url;
  814. }
  815. },
  816. loadChildren(tree, treeNode, resolve) {
  817. if (
  818. !this.emTableList.options.hasOwnProperty("lazy") ||
  819. (this.emTableList.options.hasOwnProperty("lazy") &&
  820. this.emTableList.options.lazy)
  821. ) {
  822. // 记录点击懒加载树的记录 load
  823. const key = tree[this.emTableList.rowKey];
  824. this.emTableList.loadTableTreeNodeMap.set(key, {
  825. tree,
  826. treeNode,
  827. resolve,
  828. });
  829. unitTreeChildList(this, tree, treeNode, resolve);
  830. }
  831. },
  832. formatterDef(row, column, cellValue, index) {
  833. return formatterDefault(this, row, column, cellValue, index);
  834. },
  835. switchChange(row, item) {
  836. tableListUpdateRowEvent(this, row, item);
  837. },
  838. sortReloadData(obj) {
  839. this.emTableList.sortReloadData(obj);
  840. },
  841. handleSelectionChange(val) {
  842. this.emTableList.handleSelectionChange(val);
  843. if (this.isMultipleTables) {
  844. bus.$emit("checkedEventTableToCard", val);
  845. }
  846. },
  847. cellInputEvent(item) {
  848. if (item.hasOwnProperty("isInput")) {
  849. item.isInput = true;
  850. } else {
  851. this.$set(item, "isInput", true);
  852. }
  853. },
  854. onInputBlur(row, item) {
  855. tableListUpdateRowEvent(this, row, item);
  856. },
  857. submitInputEvent(row, item) {
  858. item.isInput = false;
  859. tableListUpdateRowEvent(this, row, item);
  860. },
  861. filterColHandler(filters) {
  862. const finds = {};
  863. for (let [k, v] of Object.entries(filters)) {
  864. finds[k] = isTypeof(v) === "array" ? v.join(",") : v;
  865. }
  866. this.emTableList.paginationTick = false;
  867. this.$nextTick(() => {
  868. this.emTableList.pages.pageNum = 1;
  869. this.emTableList.searchFormList(finds);
  870. this.emTableList.paginationTick = true;
  871. });
  872. return false;
  873. },
  874. handleDisable(row, index) {
  875. return this.emTableList.handleCheckboxDisable(row, index);
  876. },
  877. handleTagClose(item, row) {
  878. tableListUpdateRowEvent(this, row, item);
  879. },
  880. handleTagListClose(item, row, tag) {
  881. let rows = Object.assign({}, row);
  882. if (isTypeof(tag) === "object") {
  883. rows = Object.assign({}, row, tag);
  884. } else {
  885. rows["tagCustomId"] = tag;
  886. }
  887. if (item.action && item.action.url) {
  888. this.handleTagClose(item, rows);
  889. }
  890. },
  891. },
  892. };
  893. </script>
  894. <style lang="scss">
  895. .el-table .select-after-line {
  896. background-color: #f0f9eb;
  897. &.el-table__row--striped td {
  898. background-color: #f0f9eb !important;
  899. }
  900. }
  901. .el-table .cell {
  902. white-space: pre-line;
  903. //解决 动态隐藏列时 单元格内容显示不全问题
  904. &.el-tooltip {
  905. width:100% !important;
  906. }
  907. .icon-name {
  908. display: inline-block;
  909. i {
  910. font-size: 12px;
  911. padding-left: 0;
  912. padding-right: 5px;
  913. }
  914. }
  915. .input-label {
  916. display: flex;
  917. align-items: center;
  918. justify-content: space-between;
  919. /*&.is-input {
  920. input {
  921. color: #409EFF;
  922. font-size: 12px;
  923. height: 23px;
  924. line-height: 23px;
  925. border-color: #f2f2f2;
  926. }
  927. i {
  928. font-size: 15px;
  929. padding-left: 10px;
  930. }
  931. }
  932. i {
  933. color: #409EFF;
  934. }*/
  935. }
  936. .table-input-form {
  937. .el-form-item__label {
  938. display: none;
  939. }
  940. .el-form-item {
  941. margin-bottom: 0;
  942. }
  943. .el-input__inner {
  944. padding: 2px 8px;
  945. }
  946. .input-label.is-input {
  947. height: 32px;
  948. i {
  949. padding-left: 0;
  950. }
  951. input {
  952. height: 28px;
  953. line-height: 28px;
  954. }
  955. }
  956. }
  957. }
  958. </style>