index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <template>
  2. <div>
  3. <ag-grid-layout
  4. toolbar
  5. :table-height="tableHeight"
  6. theme="ag-theme-alpine"
  7. :column-defs="columnDefs"
  8. :row-data="rowData"
  9. :locale-text="localeText"
  10. :grid-options="gridOptions"
  11. :default-col-def="defaultColDef"
  12. :animate-rows="true"
  13. :row-selection="rowSelection"
  14. :enable-cell-change-flash="true"
  15. @filterChanged="filterModifed"
  16. @sortChanged="gridSortChange"
  17. >
  18. <!-- @rowDoubleClicked="getList"-->
  19. <div slot="toolbar" class="inner-toolbar">
  20. <div class="toolbar-search">
  21. <en-table-search :placeholder="this.$t('action.keywords')" @search="handlerSearch" />
  22. </div>
  23. <div class="toolbar-btns">
  24. <el-button type="primary" size="mini" @click="createScreenTip">{{ this.$t('screenTip.tipAdd') }}</el-button>
  25. </div>
  26. </div>
  27. <el-pagination
  28. v-if="pageData"
  29. slot="pagination"
  30. :current-page="pageData.page_no"
  31. :page-sizes="[10, 20, 50, 100]"
  32. :page-size="pageData.page_size"
  33. layout="total, sizes, prev, pager, next, jumper"
  34. :total="pageData.data_total"
  35. @size-change="handlePageSizeChange"
  36. @current-change="handlePageCurrentChange"
  37. />
  38. </ag-grid-layout>
  39. <el-dialog :title.sync="formtitle" :visible.sync="formshow" width="35%">
  40. <div>
  41. <el-form ref="editform" :rules="rules" label-width="120px" :model="formmodel">
  42. <el-row>
  43. <el-col :span="24">
  44. <el-form-item :label="this.$t('screenTip.showText')" prop="show_text">
  45. <el-input
  46. v-model="formmodel.show_text"
  47. clearable
  48. :maxlength="100"
  49. :placeholder="this.$t('screenTip.showText')"
  50. />
  51. </el-form-item>
  52. <el-form-item :label="this.$t('screenTip.textColor')">
  53. <el-input :placeholder="this.$t('screenTip.textColor')" v-model="formmodel.text_color">
  54. <el-color-picker slot="append" color-format="hex" v-model="formmodel.text_color" size="mini"></el-color-picker>
  55. </el-input>
  56. </el-form-item>
  57. <el-form-item prop="text_size" :label="this.$t('screenTip.textSize')">
  58. <el-input v-model.number="formmodel.text_size" :placeholder="this.$t('screenTip.textSize')"><span slot="append">dp</span></el-input>
  59. </el-form-item>
  60. <el-form-item :label="this.$t('screenTip.screenBgColor')">
  61. <el-input :placeholder="this.$t('screenTip.screenBgColor')" v-model="formmodel.screen_bg_color">
  62. <el-color-picker slot="append" color-format="hex" v-model="formmodel.screen_bg_color" size="mini"></el-color-picker>
  63. </el-input>
  64. </el-form-item>
  65. <el-form-item prop="display_minutes" :label="this.$t('screenTip.displayLongest')">
  66. <el-input v-model.number="formmodel.display_minutes" :placeholder="this.$t('screenTip.displayLongest')"><span slot="append">{{this.$t('action.minute2')}}</span></el-input>
  67. </el-form-item>
  68. <el-form-item prop="bool_scroll" >
  69. <el-checkbox v-model="formmodel.bool_scroll" @change="scrollChange">{{this.$t('screenTip.boolScroll')}}</el-checkbox>
  70. </el-form-item>
  71. <el-form-item :label="this.$t('screenTip.scrollDirect')" prop="scroll_direct">
  72. <el-select v-model="formmodel.scroll_direct"
  73. :placeholder="this.$t('screenTip.scrollDirect')"
  74. filterable clearable >
  75. <el-option v-for="(item,index) in animateRender" :key="index" :label="item.key" :value="item.value" />
  76. </el-select>
  77. </el-form-item>
  78. </el-col>
  79. </el-row>
  80. </el-form>
  81. </div>
  82. <div slot="footer" class="dialog-footer">
  83. <el-button @click="formshow = false">{{ this.$t('action.cancel') }}</el-button>
  84. <el-button type="primary" @click="handlerFormSubmit('editform')">{{ this.$t('action.yes') }}</el-button>
  85. </div>
  86. </el-dialog>
  87. <!-- <el-dialog :title.sync="subscribeTitle" :visible.sync="formSubscribe" width="50%">-->
  88. <!-- <div>-->
  89. <!-- <fieldset v-for="(item,index) in channelSubscribers" v-if="item.roleName!=='管理员'" :key="index" style="margin-top: 10px">-->
  90. <!-- <legend><span style="margin-right: 10px">{{ item.roleName }} </span><el-checkbox v-model="item.allCkeck" style="float: right;" :indeterminate="item.indeterminate" @change="(checked)=>{handleCheckAll(checked,item)}">{{ choiceAll }}</el-checkbox></legend>-->
  91. <!-- <el-row :gutter="20" type="flex" style="padding: 10px">-->
  92. <!-- <el-col :span="24">-->
  93. <!-- <el-checkbox v-for="(clerk,_index) in item.clerks" :key="_index" v-model="clerk.checked" @change="handleCheckboxChanged(item)">{{ clerk.clerk_name }}</el-checkbox>-->
  94. <!-- </el-col>-->
  95. <!-- </el-row>-->
  96. <!-- </fieldset>-->
  97. <!-- </div>-->
  98. <!-- <div slot="footer" class="dialog-footer">-->
  99. <!-- <el-button @click="formSubscribe = false">{{ this.$t('action.cancel') }}</el-button>-->
  100. <!-- <el-button type="primary" @click="handlerSubscribeSubmit">{{ this.$t('action.yes') }}</el-button>-->
  101. <!-- </div>-->
  102. <!-- </el-dialog>-->
  103. </div>
  104. </template>
  105. <script>
  106. import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
  107. import ButtonCellRender from '../../components/AgGridCellRender/ButtonCellRender'
  108. import * as API_ScreenTip from '@/api/ncs_screentip'
  109. import { unix2Date } from '@/utils/Foundation'
  110. import * as API_Clerk from '@/api/ncs_clerk'
  111. import ListFilter from '@/components/AgGridCustomFilter/ListFilter'
  112. import RadioFilter from '@/components/AgGridCustomFilter/RadioFilter'
  113. import ButtonCellRenderList from "@/components/AgGridCellRender/ButtonCellRenderList";
  114. export default {
  115. name: "index",
  116. components: { ButtonCellRenderList, ButtonCellRender, ListFilter, RadioFilter },
  117. data() {
  118. return {
  119. tableData: [],
  120. /** 列表参数 */
  121. params: {
  122. page_size: 20,
  123. page_no: 1,
  124. fixedCondition: ' part_id = ' + this.$store.getters.partId
  125. },
  126. /** 新建组织弹出参数 **/
  127. formtitle: this.$t('screenTip.tipAdd'),
  128. formshow: false,
  129. /** 频道订阅设置 */
  130. // formSubscribe: false,
  131. formmodel: {},
  132. // frameGroups: [],
  133. rules: {
  134. show_text: [
  135. { required: true, message: this.$t('screenTip.showTextRequired'), trigger: 'blur' }
  136. ],
  137. scroll_direct:[{ required: false, message: this.$t('screenTip.scrollDirectRequired'), trigger: 'blur' }],
  138. display_minutes:[{ required: true, message: this.$t('screenTip.displayMinutesRequired'), trigger: 'blur' },{ type: 'number', message: this.$t('screenTip.numberRequired')}],
  139. text_size:[{ required: true, message: this.$t('screenTip.textSizeRequired'), trigger: 'blur' },{ type: 'number', message: this.$t('screenTip.numberRequired')}]
  140. },
  141. // timeRange: [new Date(2020, 11, 11, 7, 0), new Date(2020, 11, 11, 8, 0)],
  142. // checkWeek: [],
  143. /** ag-grid参数 **/
  144. pageData: [],
  145. loading: false,
  146. errorId: null,
  147. shopVisible: false,
  148. columnDefs: null,
  149. rowData: null,
  150. defaultColDef: null,
  151. gridOptions: null,
  152. gridApi: null,
  153. columnApi: null,
  154. localeText: AG_GRID_LOCALE_CN,
  155. filterState: null,
  156. rowSelection: null,
  157. frameworkComponents: null,
  158. /** 频道订阅者情况数组 */
  159. // channelSubscribers: [],
  160. // subscribeTitle: '',
  161. choiceAll: this.$t('action.choiceAll'),
  162. booleanRender: [
  163. { key: this.$t('entraceguardUser.yes'), value: true, color: 'green' },
  164. { key: this.$t('entraceguardUser.nop'), value: false, color: 'red' }
  165. ],
  166. animateRender:[
  167. {key:this.$t('screenTip.leftToRight'),value:1},
  168. {key:this.$t('screenTip.rightToLeft'),value:2},
  169. {key:this.$t('screenTip.upToDown'),value:3},
  170. {key:this.$t('screenTip.downToUp'),value:4}
  171. ]
  172. }
  173. },
  174. computed: {
  175. tableHeight() {
  176. return this.mainAreaHeight - 130
  177. }
  178. },
  179. beforeMount() {
  180. this.gridOptions = {}
  181. this.columnDefs = [
  182. {
  183. headerName: '#',
  184. headerCheckboxSelection: true,
  185. headerCheckboxSelectionFilteredOnly: true,
  186. checkboxSelection: true,
  187. sortable: false, filter: false,
  188. width: 100,
  189. resizable: false,
  190. valueGetter: this.hashValueGetter
  191. },
  192. { headerName: 'ID', field: 'id', sortable: true, filter: 'agNumberColumnFilter', width: 130 },
  193. {
  194. headerName: this.$t('screenTip.showText'), field: 'show_text', sortable: true, filter: 'agTextColumnFilter', flex: 1,
  195. cellRenderer: (para) => {
  196. return this.textShow(para)
  197. }
  198. },
  199. {
  200. headerName: this.$t('screenTip.textColor'), field: 'text_color', sortable: true, filter: 'agTextColumnFilter', width: 130,
  201. cellRenderer: (para) => {
  202. return this.colorFormatter(para)
  203. }
  204. },
  205. {
  206. headerName: this.$t('screenTip.textSize'), field: 'text_size', sortable: true, filter: 'agNumberColumnFilter', width: 130
  207. },
  208. {
  209. headerName: this.$t('screenTip.screenBgColor'), field: 'screen_bg_color', sortable: true, filter: 'agTextColumnFilter', width: 130,
  210. cellRenderer: (para) => {
  211. return this.colorFormatter(para)
  212. }
  213. },
  214. {
  215. headerName: this.$t('screenTip.displayMinutes'), field: 'display_minutes', sortable: true, filter: 'agNumberColumnFilter', width: 180
  216. },
  217. {
  218. headerName: this.$t('screenTip.boolScroll'), field: 'bool_scroll', sortable: true, filterFramework: 'RadioFilter', filterParams: {
  219. listData: this.booleanRender
  220. }, width: 150,
  221. cellRenderer: (para) => {
  222. return this.radioFilterFormatter(para, this.booleanRender)
  223. }
  224. },
  225. {
  226. headerName: this.$t('screenTip.scrollDirect'), field: 'scroll_direct', sortable: true, filterFramework: 'ListFilter', filterParams: {
  227. listData: this.animateRender
  228. }, width: 150,
  229. cellRenderer: (para) => {
  230. return this.scrollDirectFormatter(para, this.animateRender)
  231. }
  232. },
  233. // {
  234. // headerName: this.$t('screenTip.boolScroll'), field: 'bool_scroll', sortable: true, filter: 'agTextColumnFilter', width: 130
  235. // },
  236. // lockPosition 锁定位置,会在第一列
  237. // lockPinned = true 不能拖动然后固定
  238. // resizeable 单元个大小是否可以调整
  239. { headerName: this.$t('action.handle'), field: 'id',
  240. cellRendererFramework: 'ButtonCellRenderList',
  241. cellRendererParams: param => {
  242. return {
  243. list: [
  244. {
  245. onClick: this.handleEdit,
  246. label: this.$t('action.edit'),
  247. buttonType: 'primary',
  248. buttonSize: 'mini'
  249. },
  250. // {
  251. // onClick: this.manageSubscribe,
  252. // label: this.$t('channel.subscribeManage'),
  253. // buttonType: 'warning',
  254. // buttonSize: 'mini',
  255. // },
  256. // {
  257. // onClick: this.channelImHistory,
  258. // label: this.$t('channel.channelImHistory'),
  259. // buttonType: 'success',
  260. // buttonSize: 'mini',
  261. // },
  262. {
  263. onClick: this.deleteSingle,
  264. label: this.$t('action.delete'),
  265. buttonType: 'danger',
  266. buttonSize: 'mini',
  267. }
  268. ]}
  269. },
  270. filter: false,
  271. pinned: 'right',
  272. lockPinned: true,
  273. minWidth: this.$i18n.locale === 'zh' ? 200 : 300,
  274. resizable: false,
  275. sortable: false
  276. }
  277. // {
  278. // headerName: this.$t('action.edit'), field: 'id',
  279. // cellRendererFramework: 'ButtonCellRender',
  280. // cellRendererParams: {
  281. // onClick: this.handEdit,
  282. // label: this.$t('action.edit'),
  283. // buttonType: 'primary',
  284. // buttonSize: 'mini'
  285. // },
  286. // filter: false,
  287. // pinned: 'right',
  288. // lockPinned: true,
  289. // width: 100,
  290. // resizable: false,
  291. // sortable: false
  292. // },
  293. //
  294. // {
  295. // headerName: this.$t('channel.subscribeManage'), field: 'id',
  296. // cellRendererFramework: 'ButtonCellRender',
  297. // cellRendererParams: {
  298. // onClick: this.manageSubscribe,
  299. // label: this.$t('channel.subscribeManage'),
  300. // buttonType: 'success',
  301. // buttonSize: 'mini'
  302. // },
  303. // filter: false,
  304. // pinned: 'right',
  305. // lockPinned: true,
  306. // width: 100,
  307. // resizable: false,
  308. // sortable: false
  309. // },
  310. //
  311. // {
  312. // headerName: "留言历史", field: 'id',
  313. // cellRendererFramework: 'ButtonCellRender',
  314. // cellRendererParams: {
  315. // onClick: this.channelImHistory,
  316. // label: "留言历史",
  317. // buttonType: 'success',
  318. // buttonSize: 'mini'
  319. // },
  320. // filter: false,
  321. // pinned: 'right',
  322. // lockPinned: true,
  323. // width: 100,
  324. // resizable: false,
  325. // sortable: false
  326. // },
  327. //
  328. // {
  329. // headerName: this.$t('action.delete'), field: 'id',
  330. // cellRendererFramework: 'ButtonCellRender',
  331. // cellRendererParams: param => {
  332. // return {
  333. // onClick: this.deleteSingle,
  334. // label: this.$t('action.delete'),
  335. // buttonType: 'danger',
  336. // buttonSize: 'mini'
  337. // }
  338. // },
  339. // pinned: 'right',
  340. // lockPinned: true,
  341. // width: 100,
  342. // resizable: false,
  343. // filter: false,
  344. // sortable: false
  345. // }
  346. ]
  347. this.defaultColDef = {
  348. sortable: true,
  349. resizable: true,
  350. comparator: this.dateCustomComparator,
  351. filterParams: {
  352. debounceMs: 200,
  353. newRowsAction: 'keep',
  354. textCustomComparator: this.textCustomComparator,
  355. comparator: this.dateCustomComparator
  356. }
  357. }
  358. this.rowSelection = 'multiple'
  359. },
  360. mounted() {
  361. window.onresize = this.windowResize
  362. this.gridApi = this.gridOptions.api
  363. this.gridColumnApi = this.gridOptions.columnApi
  364. // 设置默认排序字段,应用列状态之后会触发 gridSortChange 函数,会调用getlist,后面不需要再调用this.getlist
  365. this.gridColumnApi.applyColumnState({
  366. state: [
  367. {
  368. colId: 'id',
  369. sort: 'asc'
  370. }
  371. ]
  372. })
  373. // this.getEmployees()
  374. },
  375. methods: {
  376. windowResize() {
  377. this.$set(this, 'mainAreaHeight', Number(document.documentElement.clientHeight) - 84)
  378. },
  379. handlerDelete(ids) {
  380. this.$confirm(this.$t('action.sureDelete'), this.$t('action.waring'), {
  381. confirmButtonText: this.$t('action.yes'),
  382. cancelButtonText: this.$t('action.cancel'),
  383. type: 'warning'
  384. }).then(() => {
  385. API_ScreenTip.remove(ids).then(
  386. response => {
  387. this.getList()
  388. this.$message({
  389. type: 'success',
  390. message: this.$t('action.deleted')
  391. })
  392. }
  393. ).catch(response => {
  394. this.$message({
  395. type: 'info',
  396. message: response.message
  397. })
  398. })
  399. }).catch(() => {
  400. this.$message({
  401. type: 'info',
  402. message: this.$t('action.cancelDelete')
  403. })
  404. })
  405. },
  406. deleteSingle(row) {
  407. this.handlerDelete(row.id)
  408. },
  409. /**
  410. * 创建频道
  411. */
  412. createScreenTip() {
  413. this.formshow = true
  414. this.formmodel = {
  415. text_color: '#FFFFFF',
  416. screen_bg_color:'#409EFF',
  417. part_id: this.$store.getters.partId
  418. }
  419. },
  420. /** 分页大小发生改变 */
  421. handlePageSizeChange(size) {
  422. this.params.page_size = size
  423. this.getList()
  424. },
  425. /** 分页页数发生改变 */
  426. handlePageCurrentChange(page) {
  427. this.params.page_no = page
  428. this.getList()
  429. },
  430. /** 加载列表数据 */
  431. getList() {
  432. this.loading = true
  433. const param = this.MixinClone(this.params)
  434. this.gridApi.showLoadingOverlay()
  435. API_ScreenTip.getList(param).then(response => {
  436. this.loading = false
  437. // this.tableData = [...response.data]
  438. this.pageData = {
  439. page_no: response.page_no,
  440. page_size: response.page_size,
  441. data_total: response.data_total
  442. }
  443. this.$nextTick(() => {
  444. const node = this.gridApi.getDisplayedRowAtIndex(0)
  445. if (node !== null && node !== undefined) {
  446. node.setSelected(true)
  447. }
  448. })
  449. this.rowData = [...response.data]
  450. this.refreshPlayStatus()
  451. }).catch(() => {
  452. this.loading = false
  453. })
  454. },
  455. /** 处理搜索 */
  456. handlerSearch(keywords) {
  457. this.params.query = keywords
  458. this.getList()
  459. },
  460. /** 处理字段排序 */
  461. tableSort(column) {
  462. if (column.order !== null) {
  463. this.params.sort = column.prop
  464. this.params.dir = column.order === 'ascending' ? 'asc' : 'desc'
  465. } else {
  466. this.params.sort = null
  467. this.params.dir = null
  468. }
  469. this.getList()
  470. },
  471. /**
  472. * 格式化unix时间戳
  473. **/
  474. unixDateFormatter(param) {
  475. if (!param.value) return ''
  476. return unix2Date(param.value * 1000)
  477. },
  478. gridSortChange(param) {
  479. const columnState = param.columnApi.getColumnState()
  480. // 排序状态
  481. const sortState = columnState.filter(function(s) {
  482. return s.sort != null
  483. }).map(function(s) {
  484. return {
  485. colId: s.colId,
  486. sort: s.sort,
  487. sortIndex: s.sortIndex
  488. }
  489. }).sort(function(a, b) {
  490. return a.sortIndex - b.sortIndex
  491. })
  492. if (sortState.length > 0) {
  493. if (sortState.length === 1) {
  494. this.params.sort = sortState[0].colId
  495. this.params.dir = sortState[0].sort
  496. } else {
  497. let sortstring = ''
  498. sortState.forEach(function(item) {
  499. sortstring += item.colId + ' ' + item.sort + ','
  500. })
  501. this.params.sort = sortstring.substring(0, sortstring.length - 1)
  502. this.params.dir = ' '
  503. }
  504. } else {
  505. delete this.params.sort
  506. delete this.params.dir
  507. }
  508. this.getList()
  509. },
  510. filterModifed(param) { // todo 通过转换后的数值过滤,需要转回原始数值
  511. var model = param.api.getFilterModel()
  512. this.params.filter = JSON.stringify(model)
  513. this.getList()
  514. },
  515. handleEdit(row) {
  516. this.formmodel = {
  517. ...row
  518. }
  519. this.formtitle=this.$t('screenTip.tipEdit')
  520. this.formshow = true
  521. },
  522. /**
  523. * 提交新增表单
  524. * @param formname
  525. */
  526. handlerFormSubmit(formName) {
  527. this.$refs[formName].validate((valid) => {
  528. if (valid) {
  529. if (!this.formmodel.id) {
  530. /** 新增 */
  531. this.formmodel.part_id = this.$store.getters.partId
  532. API_ScreenTip.add(this.formmodel).then(() => {
  533. this.formshow = false
  534. this.$message.success(this.$t('action.addSuccess'))
  535. this.getList()
  536. })
  537. } else {
  538. API_ScreenTip.update(this.formmodel.id, this.formmodel).then(() => {
  539. this.formshow = false
  540. this.$message.success(this.$t('action.editSuccess'))
  541. this.getList()
  542. })
  543. }
  544. } else {
  545. this.$message.error(this.$t('action.fromError'))
  546. }
  547. })
  548. },
  549. radioFilterFormatter(params, array) {
  550. const item = array.filter(p => p.value === params.value)[0]
  551. if (item) {
  552. if (item.color) {
  553. return '<span style="color:' + item.color + '">' + item.key + '</span>'
  554. } else {
  555. return item.key
  556. }
  557. } else {
  558. return ''
  559. }
  560. },
  561. scrollDirectFormatter(params,array){
  562. const item = array.filter(p => p.value === params.value)[0]
  563. if (item) {
  564. return item.key
  565. } else {
  566. return ''
  567. }
  568. },
  569. colorFormatter(params){
  570. return '<div style="background:' + params.value+ ';width:100%;height: 100%;"></div>'
  571. },
  572. textShow(params){
  573. console.log('pms',params)
  574. return '<div style="background:' + params.data.screen_bg_color+ ';color:'+params.data.text_color+';width:100%;height: 100%;overflow: hidden;text-align: center;"><div class="'+(params.data.bool_scroll?('animate'+params.data.scroll_direct):'')+'">'+params.value+'</div></div>'
  575. },
  576. scrollChange(val){
  577. this.rules.scroll_direct[0].required=val
  578. },
  579. // handlerSubscribeSubmit() {
  580. // let subscribeIds = []
  581. // this.channelSubscribers.forEach(item => {
  582. // subscribeIds = [...item.clerks.filter(p => p.checked).map(p => p.member_id), ...subscribeIds]
  583. // })
  584. // API_ScreenTip.setChannelSubscribers({ channel_id: this.formmodel.id, member_ids: subscribeIds.length === 0 ? null : [...subscribeIds] }).then(() => {
  585. // this.formSubscribe = false
  586. // this.$message.success(this.$t('action.editSuccess'))
  587. // })
  588. // },
  589. // manageSubscribe(row) {
  590. // this.formmodel = { ...row }
  591. // API_ScreenTip.getChannelSubscribers(row.id).then(res => {
  592. // this.channelSubscribers.forEach(item => {
  593. // item.clerks.map(k => {
  594. // k.checked = res.map(p => p.member_id).includes(k.member_id)
  595. // return k
  596. // })
  597. // const checkedLength = item.clerks.filter(p => p.checked).length
  598. // this.$set(item, 'allCkeck', item.clerks.length === checkedLength)
  599. // this.$set(item, 'indeterminate', (checkedLength !== 0) && (item.clerks.length !== checkedLength))
  600. // })
  601. // })
  602. // this.subscribeTitle = row.channel_name + this.$t('channel.subscribeManage')
  603. // this.formSubscribe = true
  604. // },
  605. // channelImHistory(row) {
  606. // this.$router.push({ name: 'channelImHistory', params: { id: row.id, callback: this.getList() }})
  607. // },
  608. // getEmployees() {
  609. // const _this = this
  610. // _this.nurses = []
  611. // API_Clerk.listByPartRoleId({ partId: this.$store.getters.partId }).then(res => {
  612. // _this.clerks = res
  613. // const groupBy = (arr, func) =>
  614. // arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => {
  615. // acc[val] = (acc[val] || []).concat(arr[i])
  616. // return acc
  617. // }, {})
  618. // const groupData = groupBy(res, item => item.role_name)
  619. // _this.nurses = Object.entries(groupData)
  620. //
  621. // _this.nurses.forEach(item => {
  622. // this.channelSubscribers.push({ 'roleName': item[0], 'clerks': item[1].map(i => { return { ...i, 'checked': false } }), 'allCheck': false, 'indeterminate': false })
  623. // })
  624. //
  625. // })
  626. // },
  627. handleCheckboxChanged(item) {
  628. this.countAllRole(item)
  629. },
  630. /** 计算传入角色组的选择情况 */
  631. countAllRole(role) {
  632. const _list = []
  633. if (!Array.isArray(role)) {
  634. if (role.clerks) _list.push(...this.countAllRole(role.clerks))
  635. } else {
  636. role.forEach(item => {
  637. _list.push(item)
  638. })
  639. }
  640. const length = _list.length
  641. const length_checked = _list.filter(_item => _item.checked).length
  642. this.$set(role, 'allCkeck', length === _list.filter(_item => _item.checked).length)
  643. this.$set(role, 'indeterminate', (length_checked !== 0) && (length !== length_checked))
  644. return _list
  645. },
  646. handleCheckAll(checked, item) {
  647. this.$set(item, 'indeterminate', false)
  648. this.setFrameCheck(item, checked)
  649. },
  650. /** 设置选择状态 */
  651. setFrameCheck(item, checked) {
  652. const perm = this.MixinClone(item)
  653. if (!Array.isArray(perm)) {
  654. this.$set(item, 'checked', checked)
  655. if (item.clerks && item.clerks.length) {
  656. this.$set(item, 'clerks', this.setFrameCheck(item.clerks, checked))
  657. }
  658. } else {
  659. perm.map(item => {
  660. item.checked = checked
  661. this.$set(item, 'checked', checked)
  662. if (item.clerks && item.clerks.length) {
  663. this.$set(item, 'clerks', this.setFrameCheck(item.clerks, checked))
  664. }
  665. })
  666. }
  667. return perm
  668. }
  669. }
  670. }
  671. </script>
  672. <style >
  673. .animate1 {
  674. white-space: nowrap;
  675. animation: 10s wordsLoop1 linear infinite normal;
  676. }
  677. .animate2 {
  678. white-space: nowrap;
  679. animation: 10s wordsLoop2 linear infinite normal;
  680. }
  681. .animate3 {
  682. white-space: nowrap;
  683. animation: 10s wordsLoop3 linear infinite normal;
  684. }
  685. .animate4 {
  686. white-space: nowrap;
  687. animation: 10s wordsLoop4 linear infinite normal;
  688. }
  689. @keyframes wordsLoop1 {
  690. 0% {
  691. transform: translateX(-100%);
  692. -webkit-transform: translateX(-100%);
  693. }
  694. 100% {
  695. transform: translateX(100%);
  696. -webkit-transform: translateX(100%);
  697. }
  698. }
  699. @-webkit-keyframes wordsLoop1 {
  700. 0% {
  701. transform: translateX(-100%);
  702. -webkit-transform: translateX(-100%);
  703. }
  704. 100% {
  705. transform: translateX(100%);
  706. -webkit-transform: translateX(100%);
  707. }
  708. }
  709. @keyframes wordsLoop2 {
  710. 0% {
  711. transform: translateX(100%);
  712. -webkit-transform: translateX(100%);
  713. }
  714. 100% {
  715. transform: translateX(-100%);
  716. -webkit-transform: translateX(-100%);
  717. }
  718. }
  719. @-webkit-keyframes wordsLoop2 {
  720. 0% {
  721. transform: translateX(100%);
  722. -webkit-transform: translateX(100%);
  723. }
  724. 100% {
  725. transform: translateX(-100%);
  726. -webkit-transform: translateX(-100%);
  727. }
  728. }
  729. @keyframes wordsLoop4 {
  730. 0% {
  731. transform: translateY(100%);
  732. -webkit-transform: translateY(100%);
  733. }
  734. 100% {
  735. transform: translateY(-100%);
  736. -webkit-transform: translateY(-100%);
  737. }
  738. }
  739. @-webkit-keyframes wordsLoop4 {
  740. 0% {
  741. transform: translateY(100%);
  742. -webkit-transform: translateY(100%);
  743. }
  744. 100% {
  745. transform: translateY(-100%);
  746. -webkit-transform: translateY(-100%);
  747. }
  748. }
  749. @keyframes wordsLoop3 {
  750. 0% {
  751. transform: translateY(-100%);
  752. -webkit-transform: translateY(-100%);
  753. }
  754. 100% {
  755. transform: translateY(100%);
  756. -webkit-transform: translateY(100%);
  757. }
  758. }
  759. @-webkit-keyframes wordsLoop3 {
  760. 0% {
  761. transform: translateY(-100%);
  762. -webkit-transform: translateY(-100%);
  763. }
  764. 100% {
  765. transform: translateY(100%);
  766. -webkit-transform: translateY(100%);
  767. }
  768. }
  769. </style>