StatisticsSparePartUsedSpare.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model="queryParam.spareName" placeholder="请输入备件名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="年份">
  13. <a-select v-model="queryParam.year" placeholder="请选择年份">
  14. <a-select-option
  15. label=""
  16. value="">全部</a-select-option>
  17. <a-select-option
  18. v-for="(value,index) in yearList"
  19. :key="index"
  20. :label="value"
  21. :value="value">{{ value }}</a-select-option>
  22. </a-select>
  23. </a-form-item>
  24. </a-col>
  25. <template v-if="advanced">
  26. <a-col :md="8" :sm="24">
  27. <a-form-item label="月份">
  28. <a-select v-model="queryParam.month" placeholder="请选择月份">
  29. <a-select-option
  30. label=""
  31. value="">全部</a-select-option>
  32. <a-select-option
  33. v-for="(value,index) in monthList"
  34. :key="index"
  35. :label="value"
  36. :value="index+1">{{ value }}</a-select-option>
  37. </a-select>
  38. </a-form-item>
  39. </a-col>
  40. </template>
  41. <a-col :md="8 || 24" :sm="24">
  42. <span class="table-page-search-submitButtons">
  43. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  44. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  45. <a @click="()=>{ this.advanced = !this.advanced}" style="margin-left: 8px">
  46. {{ advanced ? '收起' : '展开' }}
  47. <a-icon :type="advanced ? 'up' : 'down'"/>
  48. </a>
  49. </span>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </div>
  54. <div class="table-operator" style="margin-bottom: 8px;">
  55. <a-button v-if="$auth('monthly-sb-three-rates-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  56. <a-button style="margin-left: 8px" v-if="$auth('monthly-sb-three-rates-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  57. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('monthly-sb-three-rates-del')">
  58. <a-menu slot="overlay">
  59. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  60. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  61. </a-popconfirm>
  62. </a-menu>
  63. <a-button style="margin-left: 8px">
  64. 批量操作 <a-icon type="down" />
  65. </a-button>
  66. </a-dropdown>
  67. </div>
  68. <s-table
  69. ref="table"
  70. size="default"
  71. rowKey="id"
  72. :columns="columns"
  73. :data="loadData"
  74. :alert="options.alert"
  75. :rowSelection="options.rowSelection"
  76. showPagination="auto"
  77. />
  78. </a-card>
  79. </template>
  80. <script>
  81. import { STable, Ellipsis } from '@/components'
  82. import { statisticsByGroupBySparePage } from '@/api/sqarepartmanage/sparepartused'
  83. export default {
  84. name: 'MonthlySbThreeRateList',
  85. components: {
  86. STable,
  87. Ellipsis
  88. },
  89. data () {
  90. return {
  91. // 查询参数
  92. queryParam: {
  93. spareName: null,
  94. year: '',
  95. month: ''
  96. },
  97. advanced: false,
  98. yearList: [],
  99. monthList: [],
  100. // 表头
  101. columns: [
  102. {
  103. title: '序号',
  104. checked: true,
  105. dataIndex: 'index',
  106. customRender: (text, record, index) => {
  107. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  108. }
  109. },
  110. {
  111. title: '年份',
  112. checked: true,
  113. dataIndex: 'year',
  114. customRender: (text, record, index) => {
  115. return text + '年'
  116. }
  117. },
  118. {
  119. title: '月份',
  120. checked: true,
  121. dataIndex: 'month',
  122. customRender: (text, record, index) => {
  123. return text + '月'
  124. }
  125. },
  126. {
  127. title: '备件',
  128. checked: true,
  129. dataIndex: 'spareName'
  130. },
  131. {
  132. title: '更换次数',
  133. checked: true,
  134. dataIndex: 'num'
  135. }
  136. ],
  137. // 下拉框map
  138. // 加载数据方法 必须为 Promise 对象
  139. loadData: parameter => {
  140. parameter = {
  141. ...parameter,
  142. ...this.queryParam,
  143. dataScope: {
  144. }
  145. }
  146. return statisticsByGroupBySparePage(Object.assign(parameter, this.queryParam))
  147. .then(res => {
  148. for (let i = 0; i < res.data.rows.length; i++) {
  149. res.data.rows[i].id = i + ''
  150. }
  151. return res.data
  152. })
  153. },
  154. selectedRowKeys: [],
  155. selectedRows: [],
  156. options: {
  157. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  158. rowSelection: {
  159. selectedRowKeys: this.selectedRowKeys,
  160. onChange: this.onSelectChange
  161. }
  162. },
  163. optionAlertShow: false
  164. }
  165. },
  166. created () {
  167. const year = this.BaseTool.Moment().format(this.BaseTool.Date.PICKER_NORM_YEAR)
  168. const yearList = []
  169. const monthList = []
  170. for (let i = 0; i <= (year - 2015); i++) {
  171. yearList.push(year - i)
  172. }
  173. for (let i = 1; i <= 12; i++) {
  174. monthList.push(i + '月')
  175. }
  176. this.yearList = yearList
  177. this.monthList = monthList
  178. // 下拉框map
  179. this.tableOption()
  180. },
  181. methods: {
  182. tableOption () {
  183. if (!this.optionAlertShow) {
  184. this.options = {
  185. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  186. rowSelection: {
  187. selectedRowKeys: this.selectedRowKeys,
  188. onChange: this.onSelectChange,
  189. getCheckboxProps: record => ({
  190. props: {
  191. disabled: false,
  192. name: record.id
  193. }
  194. })
  195. }
  196. }
  197. this.optionAlertShow = true
  198. } else {
  199. this.options = {
  200. alert: false,
  201. rowSelection: null
  202. }
  203. this.optionAlertShow = false
  204. }
  205. },
  206. handleOk () {
  207. this.$refs.table.refresh()
  208. },
  209. onSelectChange (selectedRowKeys, selectedRows) {
  210. this.selectedRowKeys = selectedRowKeys
  211. this.selectedRows = selectedRows
  212. },
  213. resetSearchForm () {
  214. this.queryParam = {
  215. spareName: null,
  216. year: '',
  217. month: ''
  218. }
  219. this.$refs.table.refresh(true)
  220. },
  221. doExport () {
  222. const parameter = {
  223. ...this.queryParam
  224. }
  225. statisticsByGroupBySparePage(parameter).then(file => {
  226. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  227. })
  228. },
  229. handleEnter () {
  230. this.$refs.table.refresh(true)
  231. }
  232. }
  233. }
  234. </script>