| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- <template>
- <d2-container>
- <template slot="header">
- <el-form size="mini"
- ref="form"
- :inline="true"
- class="sbutton_padding"
- style="margin-top: -7px;text-align:right;">
- <el-form-item label="学年"
- class="sbutton_margin">
- <el-select v-model="search.Year"
- placeholder="请选择年级学年">
- <el-option v-for="item in years"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="学期"
- class="sbutton_margin">
- <el-select v-model="search.Term"
- style="width: 140px;">
- <el-option v-for="item in term"
- :key="item.ItemValue"
- :label="item.ItemName"
- :value="parseInt(item.ItemValue)">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="标题"
- class="sbutton_margin">
- <el-input style="width: 140px;"
- v-model="search.Title"
- placeholder="请输入标题"></el-input>
- </el-form-item>
- <el-button size="mini"
- type="primary"
- @click="initDatas()"
- style="margin-left:10px"
- @command="searchCommand"
- class="sbutton_margin">查 询</el-button>
- <el-button size="mini"
- type="primary"
- @click="clearSearch"
- class="sbutton_margin">重 置</el-button>
- <el-button size="mini"
- type="primary"
- style="margin-right:6px"
- @click="add()"
- class="sbutton_margin">添加</el-button>
- </el-form>
- </template>
- <el-table ref="multipleTable"
- :data="activities"
- border
- fit
- tooltip-effect="dark"
- style="width: 100%"
- @sort-change="orderby"
- height="100%">
- <el-table-column label="操作"
- width="180px"
- align="center"
- fixed='right'>
- <template slot-scope="scope">
- <el-button size="mini"
- title="编辑"
- type="primary"
- @click="edit(scope.row.Id)"
- icon="el-icon-edit"
- circle></el-button>
- <el-button size="mini"
- type="primary"
- title="发布"
- @click="publish(scope.row)"
- style="margin-left:5px;"
- icon="el-icon-s-promotion"
- circle></el-button>
- <el-button size="mini"
- type="primary"
- title="详情"
- icon="el-icon-notebook-2"
- circle
- @click="handleDetail(scope.row)"></el-button>
- <el-button size="mini"
- type="danger"
- title="删除"
- @click="deleteduty(scope.row.Id)"
- style="margin-left:5px;"
- icon="el-icon-delete"
- circle></el-button>
- </template>
- </el-table-column>
- <el-table-column prop="Year"
- fit
- min-width="80px"
- label="学年"
- align="center"
- show-overflow-tooltip></el-table-column>
- <el-table-column prop="Term"
- label="学期"
- align="center"
- min-width="80px"
- show-overflow-tooltip
- :formatter="formatTerm"></el-table-column>
- <el-table-column prop="Title"
- label="标题"
- align="center"
- min-width="120px"
- show-overflow-tooltip></el-table-column>
- <el-table-column prop="Status"
- label="状态"
- align="center"
- min-width="80px"
- show-overflow-tooltip
- :formatter="formatStatus"></el-table-column>
- <el-table-column prop="CreatedTime"
- label="创建日期"
- align="center"
- min-width="120px"
- show-overflow-tooltip></el-table-column>
- </el-table>
- <dutyEditDialog ref="editDialog"
- @handleClose="handleCloseAdd"
- :dutyId="dutyId"
- :term="term"
- :statusList="statusList"
- width="75"></dutyEditDialog>
- <template slot="footer">
- <el-pagination style="margin: -10px;"
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="search.page.current"
- :page-sizes="[10, 15, 20]"
- :page-size="search.page.size"
- layout="total, sizes, prev, pager, next, jumper"
- :total="search.page.total">
- </el-pagination>
- </template>
- </d2-container>
- </template>
- <script>
- import DutyApi from '@/api/duty'
- import dutyEditDialog from './components/dutyEdit'
- import itemDetailApi from '@/api/sysadmin/itemdetail'
- export default {
- name: 'duty',
- components: {
- dutyEditDialog
- },
- data () {
- return {
- dialogvisible: false,
- dutyId: -1,
- details: false,
- statusList: [],
- term: [],
- activities: [],
- Year: '',
- years: [],
- Title: '',
- Time: '',
- Status: '',
- search: {
- Term: '',
- Year: '',
- Title: '',
- page: {
- total: 0,
- current: 1,
- size: 10
- }
- },
- // 列表排序
- Column: {
- Order: '',
- Prop: ''
- }
- }
- },
- mounted () {
- this.getTerm()
- this.getStatus()
- this.initDatas()
- var myDate = new Date()
- var year = myDate.getFullYear() + 1 // 获取下年
- this.initSelectYear(year)
- },
- methods: {
- // 获取学期
- getTerm () {
- itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Term' })
- .then(res => {
- this.term = res
- })
- .catch(err => {
- console.error(err)
- })
- },
- // 匹配学期
- formatTerm (row, column) {
- for (var i = 0; i < this.term.length; i++) {
- if (parseInt(this.term[i].ItemValue) === parseInt(row.Term)) {
- return this.term[i].ItemName
- }
- }
- },
- // 获取发布状态
- getStatus () {
- let _this = this
- itemDetailApi.getItemDetailByItemCode({ ItemCode: 'PublishStatus' })
- .then(res => {
- _this.statusList = res
- this.initDatas()
- })
- .catch(err => {
- console.error(err)
- })
- },
- // 匹配状态
- formatStatus (row, column) {
- for (var i = 0; i < this.statusList.length; i++) {
- if (parseInt(this.statusList[i].ItemValue) === parseInt(row.Status)) {
- return this.statusList[i].ItemName
- }
- }
- },
- // 打开 添加弹窗
- add () {
- this.dutyId = 0
- this.$refs.editDialog.dialogvisible = true
- },
- // 打开 编辑弹窗
- edit (dutyId) {
- this.dutyId = dutyId
- this.$refs.editDialog.dialogvisible = true
- },
- publish (duty) {
- duty.Status = 1
- DutyApi.saveDuty(duty)
- },
- // 打开二级页面
- handleDetail (duty) {
- this.$router.push({ path: '/duty/detail', query: { duty: duty, term: this.term } })
- },
- // 添加 返回页面
- handleCloseAdd () {
- this.$refs.editDialog.dialogvisible = false
- this.search.page.current = 1
- this.initDatas()
- },
- // 编辑 返回页面
- handleCloseEdit () {
- this.$refs.editDialog.dialogvisible = false
- this.initDatas()
- },
- // 初始化列表数据,值班管理列表
- initDatas () {
- let _this = this
- if (!_this.CalibrationTime) {
- _this.CalibrationTime = []
- }
- let params = {
- current: this.search.page.current,
- size: this.search.page.size,
- Year: this.search.Year,
- Term: this.search.Term,
- Title: this.search.Title,
- Order: this.search.Order,
- Prop: this.search.Prop
- }
- DutyApi.getPageList(params)
- .then(res => {
- _this.activities = res.records
- _this.search.page.total = res.total
- })
- },
- handleSizeChange (val) {
- this.search.page.size = val
- this.search.page.current = 1
- this.initDatas()
- },
- handleCurrentChange (val) {
- this.search.page.current = val
- this.initDatas()
- },
- jstimehandle (val) {
- if (val === '') {
- return '----'
- } else if (val === '0001-01-01T08:00:00+08:00') {
- return '----'
- } else if (val === '5000-01-01T23:59:59+08:00') {
- return '永久'
- } else {
- if (val === '0001-01-01T00:00:00Z') {
- return '----'
- } else val = val.replace('T', ' ')
- return val.substring(0, 19)
- }
- },
- count (date2) {
- var date1 = new Date()
- var date = (date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24)/* 不用考虑闰年否 */
- return parseInt(date)
- },
- // 删除值班管理
- deleteduty (Id) {
- let _this = this
- let params = {
- id: Id
- }
- _this.$confirm('此操作将永久删除该值班信息, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '关闭',
- type: 'warning'
- }).then(() => {
- DutyApi.deleteDuty(params)
- .then(data => {
- _this.initDatas()
- })
- .catch(function (error) {
- console.log(error)
- })
- })
- .catch(() => { })
- },
- // 列表排序功能
- orderby (column) {
- if (column.order === 'ascending') {
- this.Column.Order = 'asc'
- } else if (column.order === 'descending') {
- this.Column.Order = 'desc'
- }
- this.Column.Prop = column.prop
- this.initDatas()
- },
- formatDateTime (date) {
- var y = date.getFullYear()
- var m = date.getMonth() + 1
- m = m < 10 ? '0' + m : m
- var d = date.getDate()
- d = d < 10 ? '0' + d : d
- // var h = date.getHours();
- // var minute = date.getMinutes();
- // minute = minute < 10 ? ('0' + minute) : minute;
- return y + '-' + m + '-' + d
- },
- searchCommand (command) {
- if (command === 'search') {
- this.dialogvisible = true
- } else if (command === 'clear') {
- this.clearSearch()
- }
- },
- clearSearch () {
- this.search.page.current = 1
- this.search.Year = ''
- this.search.Name = ''
- this.search.classification = ''
- this.CalibrationTime = []
- this.initDatas()
- },
- initSelectYear (year) {
- this.years = []
- for (let i = 0; i < 5; i++) {
- this.years.push({ value: (year - i), label: (year - i) + '年' })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .el-pagination {
- margin: 1rem 0 2rem;
- text-align: right;
- }
- .plab {
- font-size: 13px;
- color: #999;
- }
- </style>
|