|
@@ -0,0 +1,449 @@
|
|
|
|
+<template>
|
|
|
|
+ <div>
|
|
|
|
+ <ag-grid-layout
|
|
|
|
+ toolbar
|
|
|
|
+ :table-height="tableHeight"
|
|
|
|
+ theme="ag-theme-alpine"
|
|
|
|
+ :column-defs="columnDefs"
|
|
|
|
+ :row-data="rowData"
|
|
|
|
+ :locale-text="localeText"
|
|
|
|
+ :grid-options="gridOptions"
|
|
|
|
+ :default-col-def="defaultColDef"
|
|
|
|
+ :animate-rows="true"
|
|
|
|
+ :row-selection="rowSelection"
|
|
|
|
+ @filterChanged="filterModifed"
|
|
|
|
+ @sortChanged="gridSortChange"
|
|
|
|
+ >
|
|
|
|
+ <!-- @rowDoubleClicked="getList"-->
|
|
|
|
+ <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" size="mini" @click="createOrginazition">新建组织</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.sync="formtitle" :visible.sync="formshow" width="50%">
|
|
|
|
+ <div>
|
|
|
|
+ <el-form ref="editform" :rules="rules" label-width="120px" :model="formmodel">
|
|
|
|
+
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="组织简称" prop="shop_name">
|
|
|
|
+ <el-input v-model="formmodel.shop_name" clearable :maxlength="100" placeholder="请输入组织简称" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="16">
|
|
|
|
+ <el-form-item label="组织全称" prop="full_name">
|
|
|
|
+ <el-input v-model="formmodel.full_name" clearable :maxlength="100" placeholder="请输入组织全称" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="组织类型" prop="shop_type">
|
|
|
|
+ <el-select v-model="formmodel.shop_type" placeholder="请选择组织类型" clearable>
|
|
|
|
+ <el-option label="医院" value="6" />
|
|
|
|
+ <el-option label="科室" value="5" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+
|
|
|
|
+ <el-form-item label="管理员账号" prop="member_name">
|
|
|
|
+ <el-input v-model="formmodel.member_name" clearable :maxlength="100" placeholder="请输入管理员账号" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+
|
|
|
|
+ <el-form-item label="管理员密码" prop="member_password">
|
|
|
|
+ <el-input v-model="formmodel.member_password" type="password" clearable :maxlength="100" placeholder="请输入管理员密码" />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="8">
|
|
|
|
+ <el-form-item label="所属组织" prop="parent_id">
|
|
|
|
+ <el-select v-model="formmodel.parent_id" placeholder="请选择上级组织" clearable>
|
|
|
|
+ <el-option v-for="(item,index) in parents" :key="index" :label="item.shop_name" :value="item.shop_id" />
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </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 { AG_GRID_LOCALE_CN } from '@/utils/AgGridVueLocaleCn'
|
|
|
|
+import * as API_PartInfo from '@/api/ncs_partInfo'
|
|
|
|
+import { unix2Date } from '@/utils/Foundation'
|
|
|
|
+import ButtonCellRender from '../../components/AgGridCellRender/ButtonCellRender'
|
|
|
|
+export default {
|
|
|
|
+ name: 'Index',
|
|
|
|
+ components: { ButtonCellRender },
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ tableData: [],
|
|
|
|
+ /** 列表参数 */
|
|
|
|
+ params: {
|
|
|
|
+ page_size: 20,
|
|
|
|
+ page_no: 1
|
|
|
|
+ },
|
|
|
|
+ /** 新建组织弹出参数 **/
|
|
|
|
+ formtitle: '新建组织',
|
|
|
|
+ formshow: false,
|
|
|
|
+ formmodel: {},
|
|
|
|
+ rules: {
|
|
|
|
+ shop_name: [
|
|
|
|
+ { required: true, message: '组织名称必须选择', trigger: 'blur' }
|
|
|
|
+ ],
|
|
|
|
+ full_name: [
|
|
|
|
+ { required: true, message: '组织全称必须填写', trigger: 'blur' }
|
|
|
|
+ ],
|
|
|
|
+ shop_type: [
|
|
|
|
+ { required: true, message: '组织类型必须选择', trigger: 'blur' }
|
|
|
|
+ ],
|
|
|
|
+ member_name: [
|
|
|
|
+ { required: true, message: '管理员账号必须填写', trigger: 'blur' }
|
|
|
|
+ ],
|
|
|
|
+ member_password: [
|
|
|
|
+ { required: true, message: '管理员密码必须填写', trigger: 'blur' }
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ /** 上级机构数组 **/
|
|
|
|
+ parents: [],
|
|
|
|
+ /** ag-grid参数 **/
|
|
|
|
+ pageData: [],
|
|
|
|
+ loading: false,
|
|
|
|
+ errorId: null,
|
|
|
|
+ shopVisible: false,
|
|
|
|
+ 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: 100,
|
|
|
|
+ resizable: false,
|
|
|
|
+ valueGetter: this.hashValueGetter
|
|
|
|
+ },
|
|
|
|
+ { headerName: 'ID', field: 'shop_id', sortable: true, filter: 'agNumberColumnFilter' },
|
|
|
|
+ { headerName: '组织简称', field: 'shop_name', sortable: true, filter: 'agTextColumnFilter', filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // lockPosition 锁定位置,会在第一列
|
|
|
|
+ // lockPinned = true 不能拖动然后固定
|
|
|
|
+ // resizeable 单元个大小是否可以调整
|
|
|
|
+ { headerName: '组织全称', field: 'full_name', sortable: true, filter: 'agTextColumnFilter', filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep',
|
|
|
|
+ flex: 1
|
|
|
|
+ }},
|
|
|
|
+ { headerName: '组织类型', field: 'shop_type', sortable: true, filter: 'agTextColumnFilter', filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep',
|
|
|
|
+ flex: 1
|
|
|
|
+ },
|
|
|
|
+ cellRenderer: this.shopTypeFormatter
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ { headerName: '管理账号', field: 'member_name', sortable: true, filter: 'agTextColumnFilter', flex: 1 },
|
|
|
|
+ { headerName: '上级组织简称', field: 'parent_name', sortable: true, filter: 'agTextColumnFilter', filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ { headerName: '上级组织全称', field: 'parent_full_name', sortable: true, filter: 'agTextColumnFilter', filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep',
|
|
|
|
+ flex: 1
|
|
|
|
+ }},
|
|
|
|
+ { headerName: '编辑', field: 'shop_id',
|
|
|
|
+ cellRendererFramework: 'ButtonCellRender',
|
|
|
|
+ cellRendererParams: {
|
|
|
|
+ onClick: this.handEdit,
|
|
|
|
+ label: '编辑',
|
|
|
|
+ buttonType: 'primary',
|
|
|
|
+ buttonSize: 'mini'
|
|
|
|
+ },
|
|
|
|
+ filter: false,
|
|
|
|
+ pinned: 'right',
|
|
|
|
+ lockPinned: true,
|
|
|
|
+ width: 100,
|
|
|
|
+ resizable: false,
|
|
|
|
+ sortable: false },
|
|
|
|
+ { headerName: '删除', field: 'shop_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.dateCustomComparator,
|
|
|
|
+ filterParams: {
|
|
|
|
+ debounceMs: 200,
|
|
|
|
+ newRowsAction: 'keep',
|
|
|
|
+ textCustomComparator: this.textCustomComparator,
|
|
|
|
+ comparator: this.dateCustomComparator
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.rowSelection = 'multiple'
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.gridApi = this.gridOptions.api
|
|
|
|
+ this.gridColumnApi = this.gridOptions.columnApi
|
|
|
|
+ // var column = this.gridColumnApi.getColumn('id')
|
|
|
|
+ // const _this = this
|
|
|
|
+ // column.addEventListener('sortChanged', function(event) {
|
|
|
|
+ // console.log(event)
|
|
|
|
+ // // _this.rowData = []
|
|
|
|
+ // if (event.column.sort !== null && event.column.sort !== '') {
|
|
|
|
+ // _this.params.sort = event.column.colId
|
|
|
|
+ // _this.params.dir = event.column.sort
|
|
|
|
+ // } else {
|
|
|
|
+ // delete _this.params.sort
|
|
|
|
+ // delete _this.params.dir
|
|
|
|
+ // }
|
|
|
|
+ // _this.getList()
|
|
|
|
+ // // event.columnApi.applyColumnState({ defaultState: { sort: null }})
|
|
|
|
+ // // console.log('Column visibility changed', event)
|
|
|
|
+ // })
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ handlerDelete(ids) {
|
|
|
|
+ this.$confirm('删除操作后数据不可复原,您确定要删除此数据?', '警告', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ API_PartInfo.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: '已取消删除'
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ deleteSingle(row) {
|
|
|
|
+ this.handlerDelete(row.shop_id)
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 创建组织
|
|
|
|
+ */
|
|
|
|
+ createOrginazition() {
|
|
|
|
+ this.formshow = true
|
|
|
|
+ this.formmodel = {
|
|
|
|
+ shop_name: '',
|
|
|
|
+ full_name: '',
|
|
|
|
+ member_name: '',
|
|
|
|
+ member_password: ''
|
|
|
|
+ }
|
|
|
|
+ this.getPartents()
|
|
|
|
+ },
|
|
|
|
+ /** 分页大小发生改变 */
|
|
|
|
+ handlePageSizeChange(size) {
|
|
|
|
+ this.params.page_size = size
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /** 分页页数发生改变 */
|
|
|
|
+ handlePageCurrentChange(page) {
|
|
|
|
+ this.params.page_no = page
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
|
|
+ /** 加载列表数据 */
|
|
|
|
+ getList() {
|
|
|
|
+ this.loading = true
|
|
|
|
+ const param = this.MixinClone(this.params)
|
|
|
|
+ this.gridApi.showLoadingOverlay()
|
|
|
|
+ API_PartInfo.getList(param).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
|
|
|
|
+ }
|
|
|
|
+ this.rowData = [...response.data]
|
|
|
|
+ console.log('rowData', this.rowData)
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ this.loading = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /** 处理搜索 */
|
|
|
|
+ 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()
|
|
|
|
+ },
|
|
|
|
+ gridSortChange(param) {
|
|
|
|
+ console.log('sortparam', 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)
|
|
|
|
+ },
|
|
|
|
+ filterModifed(param) {
|
|
|
|
+ console.log(param)
|
|
|
|
+ var model = param.api.getFilterModel()
|
|
|
|
+ console.log('model', JSON.stringify(model))
|
|
|
|
+ this.params.filter = JSON.stringify(model)
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ shopTypeFormatter(param) {
|
|
|
|
+ if (param.value === '0') {
|
|
|
|
+ return '<span style="color:green">机构</span>'
|
|
|
|
+ } else if (param.value === '5') {
|
|
|
|
+ return '<span style="color:red">科室</span>'
|
|
|
|
+ } else if (param.value === '6') {
|
|
|
|
+ return '<span style="color:orange">医院</span>'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ handEdit(row) {
|
|
|
|
+ this.$router.push({ name: 'partInfoSetting', params: { id: row.shop_id, callback: this.getList() }})
|
|
|
|
+ },
|
|
|
|
+ /** 获取上级机构数组 特制医院 **/
|
|
|
|
+ getPartents() {
|
|
|
|
+ API_PartInfo.listByType(6).then(res => {
|
|
|
|
+ this.parents = [...res]
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 提交新增表单
|
|
|
|
+ * @param formname
|
|
|
|
+ */
|
|
|
|
+ handlerFormSubmit(formName) {
|
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ /** 新增 */
|
|
|
|
+ delete this.formmodel.id
|
|
|
|
+ this.formmodel.partid = this.$store.getters.partId
|
|
|
|
+ API_PartInfo.add(this.formmodel).then(() => {
|
|
|
|
+ this.formshow = false
|
|
|
|
+ this.$message.success('保存成功!')
|
|
|
|
+ this.getList()
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ this.$message.error(err)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style scoped>
|
|
|
|
+
|
|
|
|
+</style>
|