123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <template>
- <a-card :bordered="false">
- <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
- <a-form layout="inline">
- <a-row :gutter="48">
- <a-col :md="8" :sm="24">
- <a-form-item label="关键字">
- <a-input v-model="queryParam.spareName" placeholder="请输入备件名称"/>
- </a-form-item>
- </a-col>
- <a-col :md="8" :sm="24">
- <a-form-item label="年份">
- <a-select v-model="queryParam.year" placeholder="请选择年份">
- <a-select-option
- label=""
- value="">全部</a-select-option>
- <a-select-option
- v-for="(value,index) in yearList"
- :key="index"
- :label="value"
- :value="value">{{ value }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="8" :sm="24">
- <a-form-item label="月份">
- <a-select v-model="queryParam.month" placeholder="请选择月份">
- <a-select-option
- label=""
- value="">全部</a-select-option>
- <a-select-option
- v-for="(value,index) in monthList"
- :key="index"
- :label="value"
- :value="index+1">{{ value }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="8 || 24" :sm="24">
- <span class="table-page-search-submitButtons">
- <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
- <a @click="()=>{ this.advanced = !this.advanced}" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </span>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <div class="table-operator" style="margin-bottom: 8px;">
- <a-button v-if="$auth('monthly-sb-three-rates-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
- <a-button style="margin-left: 8px" v-if="$auth('monthly-sb-three-rates-export')" type="primary" icon="download" @click="doExport">导出</a-button>
- <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('monthly-sb-three-rates-del')">
- <a-menu slot="overlay">
- <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
- <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
- </a-popconfirm>
- </a-menu>
- <a-button style="margin-left: 8px">
- 批量操作 <a-icon type="down" />
- </a-button>
- </a-dropdown>
- </div>
- <s-table
- ref="table"
- size="default"
- rowKey="id"
- :columns="columns"
- :data="loadData"
- :alert="options.alert"
- :rowSelection="options.rowSelection"
- showPagination="auto"
- />
- </a-card>
- </template>
- <script>
- import { STable, Ellipsis } from '@/components'
- import { statisticsByGroupBySparePage } from '@/api/sqarepartmanage/sparepartused'
- export default {
- name: 'MonthlySbThreeRateList',
- components: {
- STable,
- Ellipsis
- },
- data () {
- return {
- // 查询参数
- queryParam: {
- spareName: null,
- year: '',
- month: ''
- },
- advanced: false,
- yearList: [],
- monthList: [],
- // 表头
- columns: [
- {
- title: '序号',
- checked: true,
- dataIndex: 'index',
- customRender: (text, record, index) => {
- return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
- }
- },
- {
- title: '年份',
- checked: true,
- dataIndex: 'year',
- customRender: (text, record, index) => {
- return text + '年'
- }
- },
- {
- title: '月份',
- checked: true,
- dataIndex: 'month',
- customRender: (text, record, index) => {
- return text + '月'
- }
- },
- {
- title: '备件',
- checked: true,
- dataIndex: 'spareName'
- },
- {
- title: '更换次数',
- checked: true,
- dataIndex: 'num'
- }
- ],
- // 下拉框map
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- parameter = {
- ...parameter,
- ...this.queryParam,
- dataScope: {
- }
- }
- return statisticsByGroupBySparePage(Object.assign(parameter, this.queryParam))
- .then(res => {
- for (let i = 0; i < res.data.rows.length; i++) {
- res.data.rows[i].id = i + ''
- }
- return res.data
- })
- },
- selectedRowKeys: [],
- selectedRows: [],
- options: {
- alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
- rowSelection: {
- selectedRowKeys: this.selectedRowKeys,
- onChange: this.onSelectChange
- }
- },
- optionAlertShow: false
- }
- },
- created () {
- const year = this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR)
- const yearList = []
- const monthList = []
- for (let i = 0; i <= (year - 2015); i++) {
- yearList.push(year - i)
- }
- for (let i = 1; i <= 12; i++) {
- monthList.push(i + '月')
- }
- this.yearList = yearList
- this.monthList = monthList
- // 下拉框map
- this.tableOption()
- },
- methods: {
- tableOption () {
- if (!this.optionAlertShow) {
- this.options = {
- alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
- rowSelection: {
- selectedRowKeys: this.selectedRowKeys,
- onChange: this.onSelectChange,
- getCheckboxProps: record => ({
- props: {
- disabled: false,
- name: record.id
- }
- })
- }
- }
- this.optionAlertShow = true
- } else {
- this.options = {
- alert: false,
- rowSelection: null
- }
- this.optionAlertShow = false
- }
- },
- handleOk () {
- this.$refs.table.refresh()
- },
- onSelectChange (selectedRowKeys, selectedRows) {
- this.selectedRowKeys = selectedRowKeys
- this.selectedRows = selectedRows
- },
- resetSearchForm () {
- this.queryParam = {
- spareName: null,
- year: '',
- month: ''
- }
- this.$refs.table.refresh(true)
- },
- doExport () {
- const parameter = {
- ...this.queryParam
- }
- statisticsByGroupBySparePage(parameter).then(file => {
- this.BaseTool.UPLOAD.downLoadExportExcel(file)
- })
- },
- handleEnter () {
- this.$refs.table.refresh(true)
- }
- }
- }
- </script>
|