|
@@ -0,0 +1,506 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+<!-- <en-table-layout-->
|
|
|
+<!-- toolbar-->
|
|
|
+<!-- @selection-change="selectFun"-->
|
|
|
+<!-- @sort-change="tableSort"-->
|
|
|
+<!-- pagination-->
|
|
|
+<!-- :tableData="tableData"-->
|
|
|
+<!-- :height="600"-->
|
|
|
+<!-- :loading="loading"-->
|
|
|
+<!-- fit-->
|
|
|
+<!-- tooltip-effect="light"-->
|
|
|
+<!-- :default-sort="{prop: 'publish_time', order: 'descending'}"-->
|
|
|
+<!-- >-->
|
|
|
+<!-- <!–工具栏–>-->
|
|
|
+<!-- <div slot="toolbar" class="inner-toolbar">-->
|
|
|
+<!-- <div class="toolbar-search">-->
|
|
|
+<!-- <en-table-search @search="handlerSearch" placeholder="请输入搜索关键字"/>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- <div class="toolbar-btns">-->
|
|
|
+<!-- <el-button type="primary" @click="handlerAdd">新增</el-button>-->
|
|
|
+<!-- <el-button type="danger" @click="batchDelete">删除</el-button>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- </div>-->
|
|
|
+<!-- <!–表头–>-->
|
|
|
+<!-- <template slot="table-columns">-->
|
|
|
+<!-- <el-table-column type="selection" width="55" align="center"></el-table-column>-->
|
|
|
+<!-- <el-table-column prop="task_content" label="内容" :formatter="contentformatter" align="left" min-width="300" :show-overflow-tooltip="true" />-->
|
|
|
+<!-- <el-table-column prop="task_plan_time" sortable="custom" label="计划任务时间" :formatter="formatterDate" align="center" width="170" />-->
|
|
|
+<!-- <el-table-column prop="task_do_time" sortable="custom" label="实际任务时间" :formatter="formatterDate2" align="center" width="170" />-->
|
|
|
+<!-- <el-table-column prop="task_success" label="任务状态" align="center">-->
|
|
|
+<!-- <template slot-scope="scope">-->
|
|
|
+<!-- <el-tag type="success" v-if="scope.row.task_result">成功</el-tag>-->
|
|
|
+<!-- <el-tag type="error" v-if="scope.row.task_result == false">失败</el-tag>-->
|
|
|
+<!-- <el-tag type="warning" v-if="scope.row.task_result == null">暂未操作</el-tag>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
+<!-- <el-table-column prop="result" label="任务结果" width="220" :show-overflow-tooltip="true"/>-->
|
|
|
+<!-- <el-table-column prop="task_do_name" label="最新操作人" width="100" align="center" />-->
|
|
|
+<!-- <el-table-column prop="create_id" label="创建人" width="100">-->
|
|
|
+<!-- <template slot-scope="scope">-->
|
|
|
+<!-- <span v-if="scope.row.create_id==0">系统</span>-->
|
|
|
+<!-- <span v-else>{{scope.row.create_name}}</span>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
+<!-- <el-table-column style="text-align: left;" label="操作" width="160" fixed="right">-->
|
|
|
+<!-- <template slot-scope="scope">-->
|
|
|
+<!-- <el-button type="success" size="mini" @click="handlerEdit(scope.$index,scope.row)">-->
|
|
|
+<!-- 操作-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button type="danger" size="mini" @click="handlerDelete(scope.row.id)">-->
|
|
|
+<!-- 删除-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- </el-table-column>-->
|
|
|
+<!-- </template>-->
|
|
|
+<!-- <!–翻页–>-->
|
|
|
+<!-- <el-pagination-->
|
|
|
+<!-- slot="pagination"-->
|
|
|
+<!-- v-if="pageData"-->
|
|
|
+<!-- :current-page="pageData.page_no"-->
|
|
|
+<!-- :page-sizes="[10, 20, 50, 100]"-->
|
|
|
+<!-- :page-size="pageData.page_size"-->
|
|
|
+<!-- @size-change="handlePageSizeChange"-->
|
|
|
+<!-- @current-change="handlePageCurrentChange"-->
|
|
|
+<!-- layout="total, sizes, prev, pager, next, jumper"-->
|
|
|
+<!-- :total="pageData.data_total">-->
|
|
|
+<!-- </el-pagination>-->
|
|
|
+<!-- </en-table-layout>-->
|
|
|
+
|
|
|
+ <ag-grid-layout
|
|
|
+ toolbar
|
|
|
+ :table-height="tableHeight"
|
|
|
+ theme="ag-theme-alpine"
|
|
|
+ :column-defs="columnDefs"
|
|
|
+ :row-data="tableData"
|
|
|
+ :locale-text="localeText"
|
|
|
+ :grid-options="gridOptions"
|
|
|
+ :default-col-def="defaultColDef"
|
|
|
+ :animate-rows="true"
|
|
|
+ :row-selection="rowSelection"
|
|
|
+ @filterChanged="filterModifed"
|
|
|
+ @sortChanged="gridSortChange"
|
|
|
+ >
|
|
|
+ <div slot="toolbar" class="inner-toolbar">
|
|
|
+ <div class="toolbar-search">
|
|
|
+ <en-table-search placeholder="请输入搜索关键字" @search="handlerSearch" />
|
|
|
+ </div>
|
|
|
+ <div class="toolbar-btns">
|
|
|
+ <el-button type="primary" @click="handlerAdd">新增</el-button>
|
|
|
+ <el-button type="danger" @click="batchDelete">删除</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-pagination
|
|
|
+ v-if="pageData"
|
|
|
+ slot="pagination"
|
|
|
+ :current-page="pageData.page_no"
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
+ :page-size="pageData.page_size"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="pageData.data_total"
|
|
|
+ @size-change="handlePageSizeChange"
|
|
|
+ @current-change="handlePageCurrentChange"
|
|
|
+ />
|
|
|
+ </ag-grid-layout>
|
|
|
+ <!--编辑表单-->
|
|
|
+ <el-dialog title="通知/任务" :visible.sync="formshow" width="50%">
|
|
|
+ <div>
|
|
|
+ <el-form ref="editform" :rules="rules" label-width="110px" :model="formmodel">
|
|
|
+ <el-form-item label="发布/计划时间" prop="publish_time">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="formmodel.publish_time"
|
|
|
+ type="datetime"
|
|
|
+ value-format="timestamp"
|
|
|
+ placeholder="选择日期时间"
|
|
|
+ align="right"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="概要" prop="subject">
|
|
|
+ <el-input clearable v-model="formmodel.subject" :maxlength="30" placeholder="请输入概要"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="内容" prop="content">
|
|
|
+ <el-input v-model="formmodel.content" type="textarea" rows="10" placeholder="请选输入内容"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="formshow = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handlerFormSubmit('editform')">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import * as API_task from '@/api/ncs_task'
|
|
|
+ import {unix2Date, unixToDate} from "@/utils/Foundation"
|
|
|
+ import { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
|
|
|
+ import Tooltip from '../../components/Tooltip/Tooltip'
|
|
|
+ import ButtonCellRender from "@/components/AgGridCellRender/ButtonCellRender";
|
|
|
+ export default {
|
|
|
+ name: 'index',
|
|
|
+ components: { Tooltip, ButtonCellRender },
|
|
|
+ data: function () {
|
|
|
+ return {
|
|
|
+ /** 表格数据 */
|
|
|
+ tableData: [],
|
|
|
+ /** 表单数据 */
|
|
|
+ formmodel: {},
|
|
|
+ formshow: false, // 编辑表单显示开关
|
|
|
+ /** 表单校验 */
|
|
|
+ rules: {
|
|
|
+ subject: [
|
|
|
+ {required: true, message: '请输入概要', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ content: [
|
|
|
+ {required: true, message: '请输入内容', trigger: 'blur'}
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ pageData: [],
|
|
|
+ loading: false,
|
|
|
+ multipleSelection: [],
|
|
|
+ params: {
|
|
|
+ page_no: 1,
|
|
|
+ page_size: 10,
|
|
|
+ sort: 'create_time',
|
|
|
+ dir: 'desc',
|
|
|
+ },
|
|
|
+ doctors: [],
|
|
|
+ memberusers: [],
|
|
|
+ editflag: 0,
|
|
|
+ columnDefs: null,
|
|
|
+ rowData: null,
|
|
|
+ defaultColDef: null,
|
|
|
+ gridOptions: null,
|
|
|
+ gridApi: null,
|
|
|
+ columnApi: null,
|
|
|
+ localeText: AG_GRID_LOCALE_CN,
|
|
|
+ filterState: null,
|
|
|
+ rowSelection: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ tableHeight() {
|
|
|
+ return this.mainAreaHeight - 130
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeMount() {
|
|
|
+ this.gridOptions = {
|
|
|
+ }
|
|
|
+ this.columnDefs = [
|
|
|
+ {
|
|
|
+ headerName: '#',
|
|
|
+ headerCheckboxSelection: true,
|
|
|
+ headerCheckboxSelectionFilteredOnly: true,
|
|
|
+ checkboxSelection: true,
|
|
|
+ sortable: false, filter: false,
|
|
|
+ width: 50,
|
|
|
+ resizable: false,
|
|
|
+ valueGetter: this.hashValueGetter
|
|
|
+ },
|
|
|
+ { headerName: '内容', field: 'task_content', sortable: true, filter: 'agTextColumnFilter', width: 400,
|
|
|
+ cellRendererFramework: 'Tooltip',
|
|
|
+ cellRendererParams: {
|
|
|
+ content: 'task_content'
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { headerName: '计划任务时间', field: 'task_plan_time', valueFormatter: this.formatterDate, sortable: true, filter: false, width: 170 },
|
|
|
+ { headerName: '实际任务时间', field: 'task_do_time', valueFormatter: this.formatterDate, sortable: true, filter: false, width: 170 },
|
|
|
+ { headerName: '任务状态', field: 'task_success', filter: false, cellRenderer: this.formatterStasus, width: 100 },
|
|
|
+ { headerName: '任务结果', field: 'task_result', sortable: true, filter: false, width: 220,
|
|
|
+ cellRendererFramework: 'Tooltip',
|
|
|
+ cellRendererParams: {
|
|
|
+ content: 'task_result'
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { headerName: '任务操作人', field: 'task_do_name', sortable: true, filter: true, width: 120 },
|
|
|
+ { headerName: '创建人', field: 'create_name', sortable: true, filter: true, width: 120},
|
|
|
+ { headerName: '操作任务', field: 'id',
|
|
|
+ cellRendererFramework: 'ButtonCellRender',
|
|
|
+ cellRendererParams: {
|
|
|
+ onClick: this.handlerEdit,
|
|
|
+ label: '操作任务',
|
|
|
+ buttonType: 'primary',
|
|
|
+ buttonSize: 'mini'
|
|
|
+ },
|
|
|
+ filter: false,
|
|
|
+ pinned: 'right',
|
|
|
+ lockPinned: true,
|
|
|
+ width: 100,
|
|
|
+ resizable: false,
|
|
|
+ sortable: false },
|
|
|
+ { headerName: '删除', field: 'id',
|
|
|
+ cellRendererFramework: 'ButtonCellRender',
|
|
|
+ cellRendererParams: {
|
|
|
+ onClick: this.deleteSingle,
|
|
|
+ label: '删除',
|
|
|
+ buttonType: 'danger',
|
|
|
+ buttonSize: 'mini'
|
|
|
+ },
|
|
|
+ pinned: 'right',
|
|
|
+ lockPinned: true,
|
|
|
+ width: 100,
|
|
|
+ resizable: false,
|
|
|
+ filter: false,
|
|
|
+ sortable: false }
|
|
|
+ ]
|
|
|
+ this.defaultColDef = {
|
|
|
+ filter: 'agTextColumnFilter',
|
|
|
+ sortable: true,
|
|
|
+ resizable: true,
|
|
|
+ comparator: this.testComparator,
|
|
|
+ filterParams: {
|
|
|
+ debounceMs: 200,
|
|
|
+ newRowsAction: 'keep',
|
|
|
+ textCustomComparator: this.textCustomComparator,
|
|
|
+ comparator: this.testComparator
|
|
|
+ }
|
|
|
+ },
|
|
|
+ this.rowSelection = 'multiple'
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.gridApi = this.gridOptions.api
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handlerAdd: function () {
|
|
|
+ this.formmodel = {}
|
|
|
+
|
|
|
+ if (this.$refs.editform) {
|
|
|
+ this.$refs.editform.resetFields()
|
|
|
+ }
|
|
|
+ this.editflag = 0
|
|
|
+ this.formshow = true
|
|
|
+ },
|
|
|
+ handlerEdit: function (index, row) {
|
|
|
+ if (this.$refs.editform) {
|
|
|
+ this.$refs.editform.resetFields()
|
|
|
+ }
|
|
|
+ this.formmodel = {
|
|
|
+ ...row
|
|
|
+ }
|
|
|
+ this.formmodel.publish_time *= 1000
|
|
|
+ this.formmodel.create_time *= 1000
|
|
|
+ this.editflag = 1
|
|
|
+ this.formshow = true
|
|
|
+ },
|
|
|
+ /** 选择行变化时,记录选中的行数据 */
|
|
|
+ selectFun(val) {
|
|
|
+ this.multipleSelection = val
|
|
|
+ },
|
|
|
+ /** 单条数据删除处理 */
|
|
|
+ handlerDelete(ids) {
|
|
|
+ this.$confirm('删除操作后数据不可复原,您确定要删除此数据?', '警告', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ API_task.remove(ids).then(
|
|
|
+ response => {
|
|
|
+ this.getList()
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ).catch(response => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: response.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 批量数据删除处理(删除选中的行) */
|
|
|
+ batchDelete: function () {
|
|
|
+ if (this.multipleSelection.length === 0) {
|
|
|
+ this.$alert('没有选择任何记录!', '系统提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ callback: action => {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const ids = []
|
|
|
+ this.multipleSelection.forEach(function (item) {
|
|
|
+ ids.push(item.id)
|
|
|
+ })
|
|
|
+
|
|
|
+ this.handlerDelete(ids.join(','))
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 分页大小发生改变 */
|
|
|
+ handlePageSizeChange(size) {
|
|
|
+ this.params.page_size = size
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ /** 分页页数发生改变 */
|
|
|
+ handlePageCurrentChange(page) {
|
|
|
+ this.params.page_no = page
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ /** 加载通知列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true
|
|
|
+ this.gridApi.showLoadingOverlay()
|
|
|
+ API_task.getList(this.params).then(response => {
|
|
|
+ this.loading = false
|
|
|
+ this.tableData = response.data
|
|
|
+ this.pageData = {
|
|
|
+ page_no: response.page_no,
|
|
|
+ page_size: response.page_size,
|
|
|
+ data_total: response.data_total
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 新增通知 提交表单 */
|
|
|
+ handlerFormSubmit(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ /** 新增通知 */
|
|
|
+ if (this.editflag === 0) {
|
|
|
+ this.formmodel.create_time = Date.parse(new Date()) / 1000
|
|
|
+ this.formmodel.publish_time = this.formmodel.publish_time / 1000
|
|
|
+ API_task.add(this.formmodel).then(() => {
|
|
|
+ this.formshow = false
|
|
|
+ this.$message.success('保存成功!')
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ /** 修改通知 */
|
|
|
+ this.formmodel.create_time /= 1000
|
|
|
+ this.formmodel.publish_time /= 1000
|
|
|
+ API_task.update(this.formmodel.id, this.formmodel).then(() => {
|
|
|
+ this.formshow = false
|
|
|
+ this.$message.success('修改成功!')
|
|
|
+ this.getList()
|
|
|
+ }).catch(response => {
|
|
|
+ this.formshow = false
|
|
|
+ this.$message.warning(response.message)
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 选择医生时把医生名字写入formodel */
|
|
|
+ doctorchange(val) {
|
|
|
+ if (val !== '') {
|
|
|
+ this.formmodel.doctor_name = this.doctors.find((item) => {
|
|
|
+ return item.member_id === val
|
|
|
+ }).uname
|
|
|
+ }
|
|
|
+ },
|
|
|
+ memberchange(val) {
|
|
|
+ if (val !== '') {
|
|
|
+ this.formmodel.member_nickname = this.memberusers.find((item) => {
|
|
|
+ return item.member_id === val
|
|
|
+ }).uname
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 处理搜索 */
|
|
|
+ handlerSearch(keywords) {
|
|
|
+ this.params.query = keywords
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ /** 处理排序 */
|
|
|
+ tableSort(column) {
|
|
|
+ if (column.order !== null) {
|
|
|
+ this.params.sort = column.prop
|
|
|
+ this.params.dir = column.order === 'ascending' ? 'asc' : 'desc'
|
|
|
+ } else {
|
|
|
+ this.params.sort = null
|
|
|
+ this.params.dir = null
|
|
|
+ }
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ formatterStasus(param) {
|
|
|
+ if(param.value) {
|
|
|
+ return '<span style="color:green">成功</span>'
|
|
|
+ } else if(param.value == false) {
|
|
|
+ return '<span style="color:red">失败</span>'
|
|
|
+ } else if(param.value == null) {
|
|
|
+ return '<span style="color:orange">暂未操作</span>'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filterModifed(param) {
|
|
|
+ console.log('filterModifed===',param)
|
|
|
+ let model = param.api.getFilterModel()
|
|
|
+ console.log('model', JSON.stringify(model))
|
|
|
+ this.params.filter = JSON.stringify(model)
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ gridSortChange(param) {
|
|
|
+ console.log('gridSortChange===', param)
|
|
|
+ const columnState = param.columnApi.getColumnState()
|
|
|
+ // 排序状态
|
|
|
+ const sortState = columnState.filter(function(s) {
|
|
|
+ return s.sort != null
|
|
|
+ }).map(function(s) {
|
|
|
+ return {
|
|
|
+ colId: s.colId,
|
|
|
+ sort: s.sort,
|
|
|
+ sortIndex: s.sortIndex
|
|
|
+ }
|
|
|
+ }).sort(function(a, b) {
|
|
|
+ return a.sortIndex - b.sortIndex
|
|
|
+ })
|
|
|
+ if (sortState.length > 0) {
|
|
|
+ if (sortState.length === 1) {
|
|
|
+ this.params.sort = sortState[0].colId
|
|
|
+ this.params.dir = sortState[0].sort
|
|
|
+ } else {
|
|
|
+ let sortstring = ''
|
|
|
+ sortState.forEach(function(item) {
|
|
|
+ sortstring += item.colId + ' ' + item.sort + ','
|
|
|
+ })
|
|
|
+ this.params.sort = sortstring.substring(0, sortstring.length - 1)
|
|
|
+ this.params.dir = ' '
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ delete this.params.sort
|
|
|
+ delete this.params.dir
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getList()
|
|
|
+ console.log(sortState)
|
|
|
+ },
|
|
|
+ formatterDate(params) {
|
|
|
+ return unixToDate(params.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style type="text/scss" scoped>
|
|
|
+ /deep/ div.toolbar {
|
|
|
+ height: 70px;
|
|
|
+ padding: 20px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-input-number, .el-select {
|
|
|
+ width: 100%
|
|
|
+ }
|
|
|
+
|
|
|
+ .inner-toolbar {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ flex-wrap: nowrap;
|
|
|
+ width: 100%;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+</style>
|