index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. <template>
  2. <div v-loading="paging.loading" class="table-wrapper">
  3. <div v-if="isExpand && analyticFeedback" style="padding-top: 10px;" v-html="analyticFeedback" />
  4. <span @click.stop>
  5. <!-- :data="[...paging.tableData].splice(0,2)" -->
  6. <!-- :data="tableData" -->
  7. <el-table
  8. :data="tableData"
  9. border
  10. style="width: 100%; margin-top: 10px"
  11. highlight-current-row
  12. row-key="rowKey"
  13. :expand-row-keys="expandRowKeys"
  14. :header-cell-style="{
  15. background: '#F7F7F7',
  16. color: '#4a4a4a',
  17. 'font-size': '14px',
  18. 'font-weight': '500'
  19. }"
  20. :cell-style="{ 'font-size': '14px', color: 'rgb(102,102,102)' }"
  21. size="small"
  22. show-overflow-tooltip="true"
  23. >
  24. <el-table-column
  25. v-for="(item, index) in setColumns(columns)"
  26. :key="item.headerKey"
  27. :data-index="index"
  28. :prop="item.headerKey"
  29. :align="item.align"
  30. :label="item.name"
  31. :type="item.type"
  32. :min-width="setMinWidth(item)"
  33. :fixed="isFixed(item, index, columns)"
  34. >
  35. <template slot-scope="scope">
  36. <!-- 展开 -->
  37. <div v-if="item.type === 'expand'">
  38. <TableExpandRow
  39. :analytic-feedback="scope.row.analyticFeedback"
  40. @upAnalyticFeedback="setAnalyticFeedback"
  41. />
  42. </div>
  43. <!-- 操作列 -->
  44. <div v-else-if="item.name === '操作'">
  45. <!-- 分析反馈 -->
  46. <div v-if="isExpand">
  47. <el-button
  48. v-if="isShowButton(scope.row, item)"
  49. type="text"
  50. @click.stop="btnFun({ value: '分析反馈' }, scope)"
  51. >
  52. 分析反馈
  53. </el-button>
  54. </div>
  55. <span v-else>
  56. <span v-for="(btnItem, btnIndex) in item.defaultValue" :key="btnIndex">
  57. <!--另存为-->
  58. <span v-if="btnItem.value === '另存为' && isShowButton(scope.row, item)" style="margin-right: 10px">
  59. <el-dropdown @command="(command) => saveAsRow(command, scope.row, item)">
  60. <el-tooltip
  61. class="item"
  62. effect="dark"
  63. content="将线上问题另存到其他业务线"
  64. placement="top"
  65. >
  66. <el-button type="text">另存</el-button>
  67. </el-tooltip>
  68. <el-dropdown-menu v-if="subReportInfo" slot="dropdown">
  69. <el-dropdown-item
  70. v-for="subItem in subReportInfo.filter(subElm => subReportInfoFilter(subElm) )"
  71. :key="subItem.id"
  72. :command="subItem">
  73. {{ subItem.reportName }}
  74. </el-dropdown-item>
  75. </el-dropdown-menu>
  76. </el-dropdown>
  77. </span>
  78. <!--链接-->
  79. <span v-else-if="btnItem.value === '链接' && isShowButton(scope.row, item)" @click.stop>
  80. <el-popover v-if="scope.row.operationTarget" placement="bottom-start" trigger="hover">
  81. <el-button-group>
  82. <el-button
  83. size="small"
  84. type="info"
  85. plain
  86. @click="goto(scope.row.operationTarget)"
  87. >
  88. 访问链接
  89. </el-button>
  90. <el-button size="small" type="info" plain @click="btnFun(btnItem, scope)">编辑</el-button>
  91. <el-button
  92. size="small"
  93. type="info"
  94. plain
  95. @click="scope.row.operationTarget = ''"
  96. >
  97. 取消链接
  98. </el-button>
  99. </el-button-group>
  100. <el-button slot="reference" style="margin-right: 10px" type="text">链接</el-button>
  101. </el-popover>
  102. <el-button
  103. v-else
  104. style="margin-right: 10px"
  105. type="text"
  106. @click.stop="btnFun(btnItem, scope)"
  107. >
  108. 链接
  109. </el-button>
  110. </span>
  111. <el-button
  112. v-else-if="isShowButton(scope.row, item)"
  113. style="margin-right: 10px"
  114. type="text"
  115. @click.stop="btnFun(btnItem, scope)"
  116. >
  117. {{ btnItem.value }}
  118. </el-button>
  119. </span>
  120. </span>
  121. </div>
  122. <!-- 其他操作区域 -->
  123. <div
  124. v-else
  125. class="edit-wrapper"
  126. :style="{ cursor: pageDate && pageDate.status < 20 ? 'pointer' : 'auto' }"
  127. >
  128. <!-- 编辑区域 -->
  129. <div v-if="editKeys.indexOf(domKey) > -1 && !item.defaultValue">
  130. <div v-if="item.displayType === 'Select'">
  131. <!-- 时间 -->
  132. <div v-if="item.selectType && item.selectType === 'Time'">
  133. <el-date-picker
  134. v-model="scope.row[item.headerKey]"
  135. type="date"
  136. style="width: 90%"
  137. value-format="yyyy-MM-dd"
  138. size="mini"
  139. placeholder="选择日期"
  140. />
  141. </div>
  142. <!-- 单选人员 -->
  143. <div v-else-if="item.selectType && item.selectType === 'SinglePeople'">
  144. <searchPeople :value.sync="scope.row[item.headerKey]" />
  145. </div>
  146. <!-- 多选人员 -->
  147. <div v-else-if="item.selectType && item.selectType === 'MultiplePeople'">
  148. <searchPeople
  149. :ref="`${scope.row.rowKey}_9867`"
  150. :value.sync="scope.row[item.headerKey]"
  151. :multiple="true"
  152. />
  153. </div>
  154. <!-- 多选人员 -->
  155. <div v-else-if="item.selectType && item.selectType === 'people'">
  156. <searchPeople :value.sync="scope.row[item.headerKey]" :multiple="true" />
  157. </div>
  158. <!-- 下拉选择 -->
  159. <el-select
  160. v-else
  161. v-model="scope.row[item.headerKey]"
  162. size="mini"
  163. placeholder="请选择"
  164. style="width: 80%"
  165. >
  166. <el-option
  167. v-for="optionItem in item.selectEnum"
  168. :key="optionItem"
  169. :label="optionItem"
  170. :value="optionItem">{{ optionItem }}
  171. </el-option>
  172. </el-select>
  173. </div>
  174. <!-- 文本域 -->
  175. <el-input
  176. v-else-if="item.displayType === 'Texterea'"
  177. v-model="scope.row[item.headerKey]"
  178. type="textarea"
  179. placeholder="请输入"
  180. :maxlength="item.name.search(/天数/) > -1 ? 10 : ''"
  181. :autosize="{ minRows: item.name.search(/天数/) > -1 ? 1 : 2, maxRows: 30 }"
  182. show-word-limit
  183. />
  184. <!-- 团队单选 -->
  185. <div v-else-if="item.displayType === 'CascaderSingle'">
  186. <CascaderSingle v-model="scope.row[item.headerKey]" />
  187. </div>
  188. <!-- 团队多选 -->
  189. <div v-else-if="item.displayType === 'Cascader'">
  190. <Cascader v-model="scope.row[item.headerKey]" @change="(value) => cascaderChange(value, scope)" />
  191. </div>
  192. <!-- 下拉选择 -->
  193. <div v-else-if="item.defaultValue === 'Select'" />
  194. <!-- 默认输入框 -->
  195. <el-input
  196. v-else
  197. v-model="scope.row[item.headerKey]"
  198. size="mini"
  199. maxlength="100"
  200. show-word-limit
  201. placeholder="请输入"
  202. />
  203. </div>
  204. <!-- 文本展示 -->
  205. <span v-else-if="item.displayType === 'Text'">{{ item.defaultValue[0].value }}</span>
  206. <!-- <div v-else class="edit-cell" @click.stop="editLine(scope.row, index)"> -->
  207. <!-- 文本展示 -->
  208. <div v-else class="edit-cell" @click.stop="editLine(scope.row, index)">
  209. <div v-if="item.displayType === 'Cascader'">
  210. <CascaderInfo :team-data="scope.row[item.headerKey]" />
  211. </div>
  212. <div v-else-if="item.displayType === 'CascaderSingle'">
  213. <CascaderSingleInfo :team-data="scope.row[item.headerKey]" />
  214. </div>
  215. <div v-else-if="item.displayType === 'Select'">
  216. <!-- 单个人员选择 -->
  217. <div v-if="item.selectType && item.selectType === 'SinglePeople'">
  218. <MultiplePeopleInfo :team-data="scope.row[item.headerKey]" />
  219. </div>
  220. <!-- 多个人员选择 -->
  221. <div v-else-if=" item.selectType && item.selectType === 'MultiplePeople'">
  222. <MultiplePeopleInfo :team-data="scope.row[item.headerKey]" />
  223. </div>
  224. <!-- 多个人员选择 -->
  225. <div v-else-if="item.selectType && item.selectType === 'people'">
  226. <MultiplePeopleInfo :team-data="scope.row[item.headerKey]" />
  227. </div>
  228. <div v-else>
  229. {{ scope.row[item.headerKey] }}
  230. </div>
  231. </div>
  232. <div
  233. v-else-if="item.displayType === 'Texterea'"
  234. :style="{
  235. cursor: item.name.search(/需求名称|问题/) > -1 && scope.row.operationTarget ? 'pointer' : 'auto',
  236. color: item.name.search(/需求名称|问题/) > -1 && scope.row.operationTarget ? '#1890ff':'#666'
  237. }"
  238. @click.stop="item.name.search(/需求名称|问题/) > -1 && pageType.search(/edit/) < 0 && goto(scope.row.operationTarget) || editLine(scope.row, index)"
  239. >
  240. <TextInfo :text-align="item.name" :text="scope.row[item.headerKey]" />
  241. </div>
  242. <div v-else>
  243. <span v-html="scope.row[item.headerKey]" />
  244. </div>
  245. </div>
  246. </div>
  247. </template>
  248. </el-table-column>
  249. </el-table>
  250. </span>
  251. <div class="plus-table-data" :style="{ marginBottom: plusTableDataBottom }" @click.stop>
  252. <el-button v-if="pageDate && pageDate.status < 20" type="text" @click.stop="addTableData">
  253. <svg-icon icon-class="data-plus" class="icon" />
  254. 新增
  255. </el-button>
  256. </div>
  257. <!-- 分页 -->
  258. <div v-if="false" class="pagination-wrapper">
  259. <el-pagination
  260. :current-page.sync="paging.curIndex"
  261. :page-size="paging.pageSize"
  262. :pager-count="5"
  263. layout="total, sizes, prev, pager, next, jumper"
  264. :page-sizes="[10, 15, 20, 30]"
  265. :total="paging.pageTotal"
  266. @size-change="handleSizeChange"
  267. @current-change="handleCurrentChange"
  268. />
  269. </div>
  270. <div />
  271. <span @click.stop>
  272. <slot name="fixedText" />
  273. <markingIssues ref="markingIssues" />
  274. <Analysis ref="Analysis" @upData="upDataAnalysis" />
  275. <LinkEdit ref="LinkEdit" @change="linkEditChange" />
  276. </span>
  277. </div>
  278. </template>
  279. <script>
  280. import _ from 'lodash'
  281. import { uuid10 } from '@/utils'
  282. import Analysis from './Analysis'
  283. import LinkEdit from './LinkEdit'
  284. import Cascader from '../Cascader'
  285. import CascaderInfo from '../CascaderInfo'
  286. import TextInfo from '../TextInfo'
  287. import MultiplePeopleInfo from '../MultiplePeopleInfo'
  288. import TableExpandRow from './TableExpandRow'
  289. import markingIssues from '../markingIssues'
  290. import CascaderSingle from '../CascaderSingle'
  291. import CascaderSingleInfo from '../CascaderSingleInfo'
  292. import searchPeople from '@/components/select/searchPeople' // 人员select
  293. import { updateAnalyticFeedback, getDeptCharge } from '@/api/qualityMonthlyReport/edit'
  294. import { reportDataBack } from '@/store/modules/monthlyReport/edit/utils.js'
  295. // import { getDeptByKeyWord } from '@/api/qualityMonthlyReport'
  296. export default {
  297. name: 'MrTable',
  298. components: {
  299. Analysis,
  300. LinkEdit,
  301. Cascader,
  302. CascaderInfo,
  303. searchPeople,
  304. MultiplePeopleInfo,
  305. TableExpandRow,
  306. markingIssues,
  307. TextInfo,
  308. CascaderSingle,
  309. CascaderSingleInfo
  310. },
  311. props: {
  312. plusTableDataBottom: {
  313. type: String,
  314. required: false,
  315. default: () => '18px'
  316. },
  317. domKey: {
  318. type: String,
  319. required: false,
  320. default: () => ''
  321. },
  322. subTitles: {
  323. type: Object,
  324. required: false,
  325. default: () => null
  326. },
  327. columns: {
  328. type: Array,
  329. required: false,
  330. default: () => []
  331. },
  332. // 分析反馈时使用的数据
  333. title: {
  334. type: String,
  335. required: false,
  336. default: () => ''
  337. },
  338. tableData: {
  339. type: Array,
  340. required: false,
  341. default: () => []
  342. }
  343. },
  344. data() {
  345. this.setAnalyticFeedback = _.debounce(this.setAnalyticFeedback, 300)
  346. return {
  347. analyticFeedback: '',
  348. expandRowKeys: [],
  349. feedbackIndex: null,
  350. username: localStorage.getItem('username'),
  351. paging: {
  352. tableData: [],
  353. curIndex: 1,
  354. pageTotal: 0,
  355. pageSize: 10,
  356. loading: false,
  357. timer: 1200
  358. }
  359. }
  360. },
  361. computed: {
  362. isExpand() {
  363. return (
  364. this.pageDate &&
  365. this.pageDate.status &&
  366. this.pageDate.status === 30 &&
  367. ((this.tabsActive.search(/本月重点问题/) > -1 &&
  368. this.pageType === 'readAll') ||
  369. (this.pageType === 'read' && this.title === '本月重点问题'))
  370. )
  371. },
  372. selectEnum() {
  373. return this.$store.state.monthlyReportEdit.selectEnum
  374. },
  375. tabPageData() {
  376. return this.$store.state.monthlyReportEdit.tabPageData
  377. },
  378. pageType() {
  379. return this.$store.state.monthlyReportEdit.pageType
  380. },
  381. tabsActive() {
  382. return this.$store.state.monthlyReportEdit.tabsActive
  383. },
  384. pageDate() {
  385. return this.$store.state.monthlyReportEdit.pageDate
  386. },
  387. roleCode() {
  388. return this.$store.state.monthlyReportEdit.roleCode
  389. },
  390. subReportName() {
  391. return this.$store.state.monthlyReportEdit.subReportName
  392. },
  393. subReportInfo() {
  394. return this.$store.state.monthlyReportEdit.subReportInfo
  395. },
  396. editKeys() {
  397. return this.$store.state.monthlyReportEdit.editKeys
  398. },
  399. isLoading() {
  400. return this.$store.state.monthlyReportEdit.isLoading
  401. }
  402. },
  403. // watch: {
  404. // tableData() {
  405. // if (this.tableData.length) {
  406. // this.init()
  407. // }
  408. // }
  409. // },
  410. mounted() {
  411. this.$nextTick(() => {
  412. this.setExpandRowKeys()
  413. this.init()
  414. })
  415. setTimeout(() => {
  416. if (!this.analyticFeedback) {
  417. this.setAnalyticFeedback()
  418. }
  419. }, 3000)
  420. },
  421. methods: {
  422. isEdit() {
  423. },
  424. init() {
  425. this.paging.curIndex = 1
  426. this.paging.pageSize = 10
  427. // console.log(this.isLoading, this.domKey)
  428. this.paging.loading = this.isLoading.indexOf(this.domKey) > -1
  429. this.paging.tableData = [...this.tableData].splice((this.paging.curIndex - 1 || 0) * this.paging.pageSize, this.paging.pageSize)
  430. this.paging.pageTotal = this.tableData.length
  431. // console.log('init', this.paging)
  432. setTimeout(() => {
  433. this.paging.loading = false
  434. }, this.paging.timer)
  435. },
  436. setMinWidth(item) {
  437. let width = 80
  438. if (item.name === '操作') {
  439. if (item.defaultValue.length) {
  440. width = item.defaultValue.length * (item.defaultValue.length > 2 ? 20 : 30)
  441. }
  442. if (this.isExpand) {
  443. width = 50
  444. }
  445. }
  446. if (item.name === '定级') {
  447. width = 70
  448. }
  449. if (item.name === '原因') {
  450. width = 150
  451. }
  452. if (item.name === '影响') {
  453. width = 100
  454. }
  455. if (item.name.search(/团队/) > -1) {
  456. width = 50
  457. }
  458. if (item.name.search(/问题/) > -1 && ((this.tabsActive.search(/本月重点问题/) > -1 &&
  459. this.pageType === 'readAll') ||
  460. (this.pageType === 'read' && this.title === '本月重点问题'))) {
  461. width = 300
  462. }
  463. if (item.name.search(/改进项/) > -1) {
  464. width = 200
  465. }
  466. if (this.pageType.search(/read/) > -1) {
  467. if (item.name.search(/标签|影响/) > -1) {
  468. width = 150
  469. }
  470. if (item.name.search(/定级|天数|类型/) > -1) {
  471. width = 35
  472. }
  473. if (item.name.search(/原因|描述/) > -1) {
  474. width = 250
  475. }
  476. if (item.name.search(/改进项/) > -1) {
  477. width = 200
  478. }
  479. if (item.name.search(/责任人|负责人|模块|团队|是否/) > -1) {
  480. width = 40
  481. }
  482. }
  483. return `${width}px`
  484. },
  485. isFixed(item, index, columns) {
  486. if (item.name === '操作') return 'right'
  487. return false
  488. },
  489. editLine(row, index) {
  490. // console.log(this.pageDate.status, this.domKey, this.editKeys)
  491. if (this.pageDate.status < 20) {
  492. this.$store.commit('monthlyReportEdit/ADD_EDIT_KEYS', this.domKey)
  493. }
  494. this.$forceUpdate()
  495. },
  496. btnFun(btnItem, scope) {
  497. this.$store.commit('monthlyReportEdit/INIT_EDIT_KEYS')
  498. if (btnItem.value === '删除') {
  499. this.tableData.splice(scope.$index, 1)
  500. }
  501. if (btnItem.value === '链接') {
  502. // console.log(scope)
  503. this.$refs['LinkEdit'].open(scope.row.operationTarget || '', scope.$index)
  504. // console.log(btnItem, scope, this.columns)
  505. }
  506. if (btnItem.value === '标记') {
  507. this.$refs.markingIssues.modalShow = true
  508. this.$nextTick(() => {
  509. this.$refs.markingIssues.openModal({
  510. title: '标记为重点问题',
  511. scope,
  512. headerTitle: this.title,
  513. columns: this.columns
  514. })
  515. })
  516. }
  517. if (btnItem.value === '分析反馈') {
  518. // console.log(293, btnItem, scope)
  519. this.$refs.Analysis.open(scope.row.analyticFeedback, scope.$index)
  520. }
  521. },
  522. // 另存为
  523. saveAsRow(command, row, item) {
  524. // console.log(414)
  525. this.$store.commit('monthlyReportEdit/SAVE_AS', {
  526. tableHeaders: this.columns,
  527. tableRows: row,
  528. subReportid: command.id
  529. })
  530. },
  531. // 分析反馈问题更新
  532. upDataAnalysis({ rowIndex, analyticFeedback }) {
  533. // console.log({ rowIndex, analyticFeedback })
  534. if (this.pageType.search(/edit/) < 0) {
  535. window.log({ c: 'report_view', d: 'report_view_Feedback' })
  536. // console.log(rowIndex, analyticFeedback)
  537. this.feedbackIndex = rowIndex
  538. this.tableData[rowIndex].analyticFeedback = _.cloneDeep(
  539. analyticFeedback
  540. )
  541. let feedbackType = ''
  542. if (analyticFeedback.hasOwnProperty('feedbackType')) {
  543. feedbackType = 'feedbackType'
  544. }
  545. this.setAnalyticFeedback(feedbackType)
  546. }
  547. },
  548. addTableData() {
  549. const item = {
  550. rowKey: uuid10()
  551. }
  552. this.columns.forEach((elm) => {
  553. item[elm.headerKey] = ''
  554. })
  555. this.tableData.push(item)
  556. this.$nextTick(() => {
  557. this.$store.commit('monthlyReportEdit/GET_ALL_OFFSETTOP')
  558. })
  559. this.editLine()
  560. },
  561. // 监听团队数据变化,动态改变问题负责人名称
  562. async cascaderChange(value, scope) {
  563. if (this.title === '本月重点问题') {
  564. // console.log({ value, scope, columns: this.columns, title: this.title })
  565. const peopleHeaderKey = this.columns.filter(elm => elm.name === '责任人')[0].headerKey
  566. const resKey = `${scope.row.rowKey}_9867`
  567. // console.log(this.$refs[resKey][0], resKey)
  568. if (value.length) {
  569. this.$refs[resKey][0].firstGetArr = true
  570. const res = await getDeptCharge({
  571. deptCode: value
  572. })
  573. scope.row[peopleHeaderKey] = Array.from(new Set(res.data.map(elm => elm.manageName)))
  574. } else {
  575. scope.row[peopleHeaderKey] = []
  576. }
  577. }
  578. },
  579. // 添加插入
  580. setColumns(columns) {
  581. let newColumns = _.cloneDeep(columns)
  582. if (this.isExpand) {
  583. newColumns = [
  584. {
  585. dataType: 'Single',
  586. defaultValue: null,
  587. displayType: 'Cascader',
  588. name: '',
  589. align: 'left',
  590. type: 'expand',
  591. selectEnum: null,
  592. selectType: null,
  593. headerKey: uuid10(6)
  594. },
  595. ...newColumns
  596. ]
  597. newColumns[1].align = 'left'
  598. }
  599. newColumns.forEach((elm) => {
  600. if (!elm.align) {
  601. elm.align = 'center'
  602. }
  603. })
  604. // if (this.pageDate.status > 10 && this.tabsActive.indexOf('本月重点问题') < 0) {
  605. // 非编辑状态,并且不是·本月重点问题·,删除操作按钮
  606. if (this.pageDate && this.pageDate.status > 10 && !this.isExpand) {
  607. newColumns.splice(newColumns.length - 1, 1)
  608. }
  609. return newColumns
  610. },
  611. arraySpanMethod({ row, column, rowIndex, columnIndex }) {
  612. if (
  613. columnIndex === 0 &&
  614. this.tabsActive.indexOf('本月重点问题') > -1 &&
  615. this.pageType.search(/edit/) < 0
  616. ) {
  617. return [1, 2]
  618. } else if (columnIndex === 1) {
  619. return [0, 0]
  620. }
  621. },
  622. // 查看页面数据分析
  623. setAnalyticFeedback(key = '') {
  624. if (
  625. // this.pageType.search(/edit/) < 0 &&
  626. // this.pageDate.status > 10 &&
  627. // this.tabsActive.indexOf('本月重点问题') > -1
  628. this.isExpand
  629. ) {
  630. const tabPageData = reportDataBack(_.cloneDeep(this.tabPageData))
  631. let obj = null
  632. const run = (arr) => {
  633. arr.forEach((elm) => {
  634. if (elm.domKey === this.domKey) {
  635. // console.log(elm)
  636. obj = _.cloneDeep(elm)
  637. }
  638. if (elm.content.length) {
  639. elm.content.forEach((item) => {
  640. if (item.domKey === this.domKey) {
  641. // console.log(elm)
  642. obj = _.cloneDeep(elm)
  643. }
  644. })
  645. }
  646. if (elm.children.length) {
  647. run(elm.children)
  648. }
  649. })
  650. }
  651. run(tabPageData.children)
  652. const params = {
  653. reportId: this.$route.query.reportId,
  654. subReportName: this.subReportName,
  655. feedbackIndex: this.feedbackIndex,
  656. reportCatalog: obj
  657. }
  658. if (this.$route.query.pageType === 'readAll' && obj) {
  659. params.subReportName = `${obj.title}`
  660. }
  661. // console.log(params)
  662. // 提交数据
  663. if (obj && obj.content[0].tableRows.length) {
  664. if (key && key === 'feedbackType') {
  665. params[key] = 'feedback_commit'
  666. }
  667. updateAnalyticFeedback(params).then((res) => {
  668. if (res.code === 200) {
  669. this.analyticFeedback = res.data
  670. if (this.analyticFeedback.search(/yellow/) > -1) {
  671. this.analyticFeedback = this.analyticFeedback.replace(
  672. /yellow/g,
  673. '#FAAD14'
  674. )
  675. }
  676. if (this.analyticFeedback.search(/green/) > -1) {
  677. this.analyticFeedback = this.analyticFeedback.replace(
  678. /green/g,
  679. '#7ED321'
  680. )
  681. }
  682. // this.analyticFeedback = res.data
  683. }
  684. })
  685. }
  686. }
  687. },
  688. /**
  689. * 操作按钮是否显示隐藏
  690. * 1、首先判断 页面 为编辑页面时 展示所有按钮
  691. * 2、判读分析反馈是否已经提交,已经提交的话,不展示按钮
  692. * 3、再判断当前表格是否有责任人
  693. * 有责任人
  694. * 判断当前用户是否存在负责人中,存在展示按钮,不存在则不展示
  695. * 无责任人不展示按钮
  696. * @param row 表格行数据
  697. * @returns {boolean}
  698. */
  699. isShowButton(row) {
  700. if (
  701. this.pageType.search(/edit/) > -1 &&
  702. this.pageDate &&
  703. this.pageDate.status < 20
  704. ) {
  705. return true
  706. }
  707. if (row.analyticFeedback && row.analyticFeedback.isCommitted) {
  708. return false
  709. }
  710. // 默认所有情况都展示
  711. if (this.pageType) {
  712. return true
  713. }
  714. if (this.roleCode === 100 || this.roleCode === 0) return true
  715. if (this.pageDate.createBy === this.username) return true
  716. for (let i = 0; i < this.columns.length; i++) {
  717. const elm = this.columns[i]
  718. if (elm.name === '责任人') {
  719. if (!row[elm.headrKey]) return true
  720. return row[elm.headrKey].indexOf(this.username) > -1
  721. }
  722. }
  723. return false
  724. },
  725. setExpandRowKeys() {
  726. if (this.isExpand && this.tableData && this.tableData.length) {
  727. this.tableData.forEach((elm) => {
  728. if (
  729. elm.analyticFeedback &&
  730. elm.analyticFeedback.hasOwnProperty('isCommitted') &&
  731. elm.analyticFeedback.isCommitted &&
  732. this.expandRowKeys.indexOf(elm.rowKey) < 0
  733. ) {
  734. this.expandRowKeys.push(elm.rowKey)
  735. }
  736. })
  737. }
  738. },
  739. subReportInfoFilter(elm) {
  740. const { subReportId } = this.$route.query
  741. if (this.pageType === 'edit') {
  742. return `${elm.id}` !== `${subReportId}`
  743. }
  744. return this.tabsActive.indexOf(elm.id) < 0
  745. },
  746. // 修改链接
  747. linkEditChange({ rowIndex, addresLink }) {
  748. // console.log(rowIndex, addresLink)
  749. this.tableData[rowIndex].operationTarget = addresLink
  750. },
  751. /* S 分页 */
  752. handleSizeChange(value) {
  753. this.paging.loading = true
  754. // console.log('handleSizeChange', value)
  755. this.paging.pageSize = value
  756. this.paging.tableData = [...this.tableData].splice((this.paging.curIndex - 1 || 0) * this.paging.pageSize, this.paging.pageSize)
  757. setTimeout(() => {
  758. this.paging.loading = false
  759. }, this.paging.timer)
  760. },
  761. handleCurrentChange(value) {
  762. this.paging.loading = true
  763. // console.log('handleCurrentChange', value)
  764. this.paging.curIndex = value
  765. this.paging.tableData = [...this.tableData].splice((this.paging.curIndex - 1 || 0) * this.paging.pageSize, this.paging.pageSize)
  766. setTimeout(() => {
  767. this.paging.loading = false
  768. }, this.paging.timer)
  769. },
  770. /* E 分页 */
  771. // 页面跳转
  772. goto(url) {
  773. // console.log(url)
  774. url && window.open(url, '_blank')
  775. }
  776. }
  777. }
  778. </script>
  779. <style scoped lang='less'>
  780. .table-wrapper{
  781. position: relative;
  782. .pagination-wrapper{
  783. position: absolute;
  784. right: 0;
  785. bottom: 5px;
  786. .el-pagination{
  787. margin: 0;
  788. }
  789. }
  790. }
  791. .edit-wrapper {
  792. .edit-cell {
  793. min-height: 23px;
  794. width: 100%;
  795. }
  796. }
  797. .plus-table-data {
  798. margin-top: 2px;
  799. }
  800. /deep/ .el-table__expand-column {
  801. border-right: 0;
  802. .el-icon-arrow-right:before {
  803. // 这是展开图标
  804. border: 1px solid rgba(0, 0, 0, 0.14901960784313725);
  805. }
  806. }
  807. /deep/ .el-table__expand-column .cell {
  808. .el-table__expand-icon {
  809. .el-icon-arrow-right:before {
  810. // 这是展开图标
  811. content: '\e6d9';
  812. //content: "\e6d8";
  813. }
  814. }
  815. .el-table__expand-icon--expanded {
  816. // 这是点击后的旋转角度
  817. //transform: rotate(180deg);
  818. transform: rotate(0deg);
  819. .el-icon-arrow-right:before {
  820. // 这是展开图标
  821. //content: "\e6d9";
  822. content: '\e6d8' !important;
  823. }
  824. }
  825. }
  826. /deep/ .svg-icon {
  827. width: 1em;
  828. height: 1em;
  829. }
  830. /deep/ .el-table__expanded-cell {
  831. padding-bottom: 0;
  832. padding-left: 60px;
  833. }
  834. /deep/ .el-button {
  835. font-weight: 400;
  836. }
  837. /deep/ .red {
  838. color: red;
  839. }
  840. /deep/ .green {
  841. color: green;
  842. }
  843. /deep/ .yellow {
  844. color: yellow;
  845. }
  846. </style>