tableList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div id="tableList">
  3. <el-table
  4. :data="tableData"
  5. :span-method="objectSpanMethod"
  6. stripe
  7. style="width: 100%"
  8. @select-all="selectAll"
  9. @select="select"
  10. @sort-change="sortChange"
  11. :row-key="rowKey"
  12. :load="load"
  13. :cell-style="timeStyle"
  14. lazy
  15. :border="true"
  16. ref="pagerset"
  17. v-loading="loading"
  18. :row-class-name="navText.tableColor ? navText.tableColorFunc : ''"
  19. :header-cell-style="{
  20. 'background-color': '#eee',
  21. color: '#333',
  22. fontSize: '14px',
  23. }"
  24. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  25. >
  26. <el-table-column
  27. v-if="navText.choiceRadio"
  28. align="center"
  29. type="selection"
  30. :fixed="navText.radioFixed"
  31. width="55"
  32. >
  33. <template slot-scope="scope">
  34. <el-radio
  35. style="margin-left: 10px"
  36. v-model="tableRadio"
  37. :label="scope.row[navText.radioKey]"
  38. @change="radioChange"
  39. >{{ "" }}</el-radio
  40. >
  41. </template>
  42. </el-table-column>
  43. <el-table-column
  44. v-if="navText.choice"
  45. :reserve-selection="navText.openCheckMore"
  46. align="center"
  47. type="selection"
  48. width="55"
  49. header-align="center"
  50. fixed="left"
  51. :selectable="
  52. navText.selectableStatus ? navText.selectableFunc : selectFuncTrue
  53. "
  54. >
  55. </el-table-column>
  56. <el-table-column
  57. v-if="navText.dontNum ? false : true"
  58. type="index"
  59. :index="setIndex"
  60. label="序号"
  61. width="70"
  62. align="center"
  63. header-align="center"
  64. >
  65. </el-table-column>
  66. <af-table-column
  67. v-for="(item, index) in compTableSet(tableSet)"
  68. :width="item.width"
  69. :label="item.label"
  70. :align="item.dontCenter ? 'left' : 'center'"
  71. :sortable="item.prop === 'sort' || item.sort"
  72. :sort-method="sortMethods"
  73. :show-overflow-tooltip="item.showTooltip ? false : true"
  74. header-align="center"
  75. :prop="item.prop"
  76. sort-by="sort"
  77. :key="index"
  78. >
  79. <template slot-scope="scope">
  80. <div class="imgboxsq" v-if="item.scope === 'img'">
  81. <img
  82. style="height: 60px; width: 60px"
  83. v-if="!scope.row[item.prop]"
  84. src="@/assets/404_images/wuyuxaog.png"
  85. alt=""
  86. />
  87. <el-image
  88. v-else
  89. class="el_images"
  90. lazy
  91. :src="$methodsTools.splitImgHost(scope.row[item.prop])"
  92. style="height: 100%; width: 100%"
  93. :preview-src-list="[
  94. $methodsTools.splitImgHost(scope.row[item.prop]),
  95. ]"
  96. alt="加载失败"
  97. >
  98. </el-image>
  99. </div>
  100. <div v-else-if="item.scope === 'sortType'">
  101. <el-input-number
  102. v-model="scope.row[item.prop]"
  103. :min="0"
  104. style="width: 80px"
  105. :controls="false"
  106. @change="blurBackData(scope.row)"
  107. ></el-input-number>
  108. </div>
  109. <template
  110. v-else-if="
  111. item.scope === 'copyTime' && scope.row[item.prop] != null
  112. "
  113. >
  114. <div v-for="(item, index) in scope.row['copyTime']" :key="index">
  115. <span>{{ item }}</span>
  116. </div>
  117. </template>
  118. <span v-else-if="item.scope === 'sex'">
  119. {{
  120. scope.row[item.prop] == 1
  121. ? "男"
  122. : scope.row[item.prop] == 2
  123. ? "女"
  124. : "未知"
  125. }}
  126. </span>
  127. <span v-else-if="item.scope === 'TimeLists'"
  128. >{{ $methodsTools.onlyForma(scope.row[item.prop1], item.Diszing) }}
  129. {{ scope.row[item.prop1] ? "至" : "" }}
  130. {{
  131. $methodsTools.onlyForma(scope.row[item.prop2], item.Diszing)
  132. }}</span
  133. >
  134. <span v-else-if="item.scope === 'aTimeList'">{{
  135. scope.row[item.prop] === null
  136. ? "--"
  137. : $methodsTools.onlyForma(scope.row[item.prop], !item.isDiszing)
  138. }}</span>
  139. <span v-else-if="item.scope === 'time'">{{
  140. numTime(scope.row[item.prop])
  141. }}</span>
  142. <div v-else-if="item.scope === 'isOptions'">
  143. <template v-for="(itemt, indext) in item.options">
  144. <span
  145. :key="indext"
  146. v-if="itemt.value === scope.row[item.prop]"
  147. :style="itemt.style ? itemt.style : ''"
  148. >{{ itemt.label }}
  149. <el-button
  150. type="text"
  151. v-if="itemt.click"
  152. @click="backFunc(scope.row)"
  153. >查看</el-button
  154. ></span
  155. >
  156. </template>
  157. </div>
  158. <span v-else-if="item.scope === 'isgzhOpenId'">{{
  159. scope.row[item.prop] ? "是" : "否"
  160. }}</span>
  161. <span v-else-if="item.scope === 'InfoMore'"
  162. >{{ scope.row[item.prop1] }} - {{ scope.row[item.prop2] }}
  163. </span>
  164. <span v-else-if="item.scope === 'type'">
  165. {{ item.values[scope.row[item.prop]] }}
  166. </span>
  167. <span v-else-if="item.scope === 'peopleNums'">
  168. {{ scope.row[item.prop1] }} / {{ scope.row[item.prop2] }}
  169. </span>
  170. <div v-else-if="item.scope === 'solt'">
  171. <slot :name="item.soltName" :scope="scope"></slot>
  172. </div>
  173. <span v-else>
  174. {{ scope.row[item.prop] }}
  175. {{
  176. (scope.row[item.prop] || scope.row[item.prop] === 0) && item.ch
  177. ? item.ch
  178. : ""
  179. }}
  180. </span>
  181. </template>
  182. </af-table-column>
  183. <el-table-column
  184. label="操作"
  185. align="center"
  186. fixed="right"
  187. :width="navText.changeWidth ? navText.changeWidth : '180px'"
  188. v-if="!navText.tableHide"
  189. >
  190. <template slot-scope="scope">
  191. <slot name="btn" :scope="scope"></slot>
  192. </template>
  193. </el-table-column>
  194. </el-table>
  195. </div>
  196. </template>
  197. <script>
  198. export default {
  199. props: [
  200. "tableSets",
  201. "tableData",
  202. "navText",
  203. "rowKey",
  204. "loading",
  205. "objectSpanMethod",
  206. "setIndex",
  207. "radio",
  208. ],
  209. data: function () {
  210. return {
  211. tableSet: this.tableSets,
  212. allCheckData: [], //表格多选
  213. isIndeterminate: false,
  214. props: {
  215. label(data, node) {
  216. return data.menuName || data.name;
  217. },
  218. isLeaf(data, node) {
  219. return data.hasChildren ? false : true;
  220. },
  221. },
  222. treeDatas: [],
  223. treeDatas1: [],
  224. treeDatas2: [],
  225. };
  226. },
  227. computed: {
  228. tableRadio: {
  229. get() {
  230. return this.radio;
  231. },
  232. set(val) {
  233. this.$emit("update:radio", val);
  234. },
  235. },
  236. compTableSet: function () {
  237. return function (options) {
  238. var arrays = options.filter((item) => {
  239. return item.hidden !== false;
  240. });
  241. return arrays;
  242. };
  243. },
  244. numTime: function () {
  245. return function (res) {
  246. return Number(res / 3600).toFixed(2);
  247. };
  248. },
  249. },
  250. created() {
  251. this.inittableSet = JSON.stringify(this.tableSet);
  252. this.initTR();
  253. },
  254. methods: {
  255. selectFuncTrue() {
  256. return true;
  257. },
  258. radioChange(val) {},
  259. blurBackData(row) {
  260. this.$emit("sortFunc", row);
  261. },
  262. backFunc(row) {
  263. this.$emit("backFunc", row);
  264. },
  265. /**
  266. * 清除多选框
  267. */
  268. clearMoreActive() {
  269. this.allCheckData = [];
  270. this.$refs.pagerset.clearSelection();
  271. },
  272. openDialog(row) {
  273. this.$emit("openDialog", row);
  274. },
  275. sortMethods(a, b) {
  276. if (a.classGradeUserGoodsVoList && b.classGradeUserGoodsVoList) {
  277. return a.classGradeUserGoodsVoList.length >
  278. b.classGradeUserGoodsVoList.length
  279. ? -1
  280. : 1;
  281. } else {
  282. return a.sort > b.sort ? -1 : 1;
  283. }
  284. },
  285. sortChange(column) {
  286. this.$emit("sortChange", column);
  287. },
  288. openSpec(id) {
  289. this.$emit("openClassNum", id);
  290. },
  291. loadNode(node, resolve) {
  292. if (node.level === 0) {
  293. this.treeDatas.forEach((item) => {
  294. if (item.type === 1) {
  295. item.hasChildren = true;
  296. }
  297. if (item.type === 2) {
  298. item.hasChildren = true;
  299. }
  300. if (item.type === 3) {
  301. item.hasChildren = false;
  302. }
  303. });
  304. return resolve(this.treeDatas);
  305. } else {
  306. if (node.data.type === 1) {
  307. this.$api
  308. .inquireCourseListmodulechapter(node.data.menuId)
  309. .then((res) => {
  310. res.data.forEach((item) => {
  311. item.TypeId = 2 + "-" + item.chapterId;
  312. item.hasChildren = true;
  313. item.menuId = item.chapterId;
  314. item.type = 2;
  315. });
  316. return resolve(res.data);
  317. });
  318. }
  319. if (node.data.type === 2) {
  320. this.$api
  321. .inquireCoursechaptersectionlist(node.data.menuId)
  322. .then((res) => {
  323. res.data.forEach((item) => {
  324. item.TypeId = 3 + "-" + item.sectionId;
  325. item.type = 3;
  326. });
  327. return resolve(res.data);
  328. });
  329. }
  330. if (node.data.type === 3) {
  331. return resolve([]);
  332. }
  333. }
  334. },
  335. openBoxData(row) {
  336. this.$emit("openBoxFun", row);
  337. },
  338. timeStyle(column) {
  339. if (column.columnIndex === 0 && this.navText.firstColLeft) {
  340. return "text-align:left!important; padding-left: 40px;";
  341. }
  342. },
  343. //初始化
  344. initTR() {
  345. this.isIndeterminate = false;
  346. this.tableSet = [];
  347. this.$nextTick(() => {
  348. this.tableSet = JSON.parse(this.inittableSet);
  349. });
  350. },
  351. edit() {},
  352. selectAll(value) {
  353. this.allCheckData = value;
  354. },
  355. select(value) {
  356. this.allCheckData = value;
  357. },
  358. load(tree, treeNode, resolve) {
  359. this.$emit("load", tree, treeNode, resolve);
  360. },
  361. },
  362. };
  363. </script>
  364. <style lang="less">
  365. .el-table .info-row {
  366. background: #c9c9c9;
  367. }
  368. .open_style {
  369. cursor: pointer;
  370. color: blue;
  371. }
  372. .el-table .cell.el-tooltip {
  373. transition: all 0.3s;
  374. }
  375. .max-heightStyles {
  376. max-height: 500px;
  377. overflow-y: auto;
  378. }
  379. .overSty {
  380. white-space: nowrap;
  381. overflow-x: auto;
  382. &::-webkit-scrollbar {
  383. width: 14px;
  384. height: 14px;
  385. }
  386. &::-webkit-scrollbar-track,
  387. &::-webkit-scrollbar-thumb {
  388. border-radius: 999px;
  389. border: 5px solid transparent;
  390. }
  391. &::-webkit-scrollbar-track {
  392. box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2) inset;
  393. }
  394. &::-webkit-scrollbar-thumb {
  395. min-height: 20px;
  396. background-clip: content-box;
  397. box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.2) inset;
  398. }
  399. &::-webkit-scrollbar-corner {
  400. background: transparent;
  401. }
  402. }
  403. .slotPopper {
  404. padding: 0px !important;
  405. }
  406. </style>
  407. <style lang="less" scoped>
  408. #tableList {
  409. border-radius: 8px;
  410. }
  411. .goodsListStyle {
  412. cursor: pointer;
  413. color: blue;
  414. }
  415. .popoverDis {
  416. display: flex;
  417. flex-direction: column;
  418. align-items: flex-start;
  419. font-size: 14px;
  420. .checkboxHeader {
  421. height: 40px;
  422. display: flex;
  423. align-items: center;
  424. justify-content: space-between;
  425. padding-left: 13px;
  426. padding-right: 15px;
  427. width: 100%;
  428. .initbtns {
  429. color: #47a6ff;
  430. cursor: pointer;
  431. }
  432. }
  433. .checkboxGroup {
  434. display: flex;
  435. flex-direction: column;
  436. width: 100%;
  437. .checkboxchild {
  438. width: 100%;
  439. justify-content: space-between;
  440. height: 40px;
  441. display: flex;
  442. align-items: center;
  443. padding: 0px 15px 0px 13px;
  444. transition: all 0.4s;
  445. &:hover {
  446. background-color: #ecf5ff;
  447. }
  448. &:hover .icon-right {
  449. display: flex;
  450. }
  451. .icon-right {
  452. display: flex;
  453. align-items: center;
  454. width: 30px;
  455. height: 30px;
  456. color: #666;
  457. font-size: 14px;
  458. display: none;
  459. i {
  460. cursor: pointer;
  461. margin: 0px 3px;
  462. &:hover {
  463. color: #47a6ff;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. }
  470. /deep/.el-checkbox__input.is-checked + .el-checkbox__label {
  471. color: #666;
  472. }
  473. .imgboxsq {
  474. margin: 0 auto;
  475. height: 60px;
  476. max-height: 60px;
  477. .el_images {
  478. /deep/.el-image__inner {
  479. width: auto;
  480. }
  481. }
  482. }
  483. .imgHover {
  484. width: 100%;
  485. height: 100%;
  486. cursor: pointer;
  487. }
  488. .cvideo {
  489. transition: all 0.2s;
  490. color: #333;
  491. cursor: pointer;
  492. font-size: 30px;
  493. }
  494. .cvideo:hover {
  495. color: #47a6ff;
  496. }
  497. .ulAuto {
  498. display: flex;
  499. justify-content: center;
  500. align-items: center;
  501. & > ul {
  502. margin: 0px;
  503. }
  504. }
  505. .ulAutos {
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. }
  510. .el-popover > ul {
  511. margin: 0px;
  512. }
  513. .dis_sdt {
  514. display: flex;
  515. align-items: flex-end;
  516. ul {
  517. margin: 0px;
  518. li {
  519. text-align: left;
  520. }
  521. }
  522. }
  523. .jumpStys {
  524. color: blue;
  525. cursor: pointer;
  526. }
  527. .zdyBoxStyle {
  528. display: flex;
  529. align-items: center;
  530. justify-content: center;
  531. .zdyBtnstyle {
  532. padding: 4px 16px;
  533. border-radius: 4px;
  534. border: 1px solid #666;
  535. color: #666;
  536. cursor: pointer;
  537. }
  538. .goodsActiveStyle {
  539. color: #fff;
  540. background-color: #409eff;
  541. border-color: #409eff;
  542. }
  543. }
  544. .liSYTS {
  545. padding: 10px;
  546. margin-bottom: 16px;
  547. background: #eee;
  548. width: 96%;
  549. }
  550. .overBoxs {
  551. max-height: 500px;
  552. overflow-y: auto;
  553. }
  554. </style>