SpareStoreTotal.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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="6" :sm="24">
  7. <a-form-item label="关键字">
  8. <a-input v-model="queryParam.keyword" placeholder="请输入备件名称/备件编码"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="6" :sm="24">
  12. <a-form-item label="所属公司">
  13. <a-select @change="handleCompanyChange" v-model="queryParam.useCompany" placeholder="请选择">
  14. <a-select-option
  15. v-for="({deptId, name}) in companyList"
  16. :key="deptId"
  17. :label="name"
  18. :value="deptId">{{ name }}
  19. </a-select-option>
  20. </a-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="所属项目">
  25. <a-select v-model="queryParam.useProject" placeholder="请选择">
  26. <a-select-option
  27. v-for="({deptId, name}) in projectList"
  28. :key="deptId"
  29. :label="name"
  30. :value="deptId">{{ name }}
  31. </a-select-option>
  32. </a-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-item label="备件类别">
  37. <a-tree-select
  38. style="width: 100%"
  39. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  40. :treeData="spareTypeTreeData"
  41. :treeNodeFilterProp="'title'"
  42. :showSearch="true"
  43. v-model="queryParam.typeId"
  44. placeholder="请选择"
  45. >
  46. </a-tree-select>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6 || 24" :sm="24">
  50. <span class="table-page-search-submitButtons">
  51. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  52. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  53. </span>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <div class="table-operator">
  59. <!--<a-button v-if="$auth('store-spare-stores-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
  60. <a-button style="margin-left: 8px" v-if="$auth('store-spare-stores-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  61. </div>
  62. <s-table
  63. ref="table"
  64. size="default"
  65. rowKey="spareId"
  66. :columns="columns"
  67. :data="loadData"
  68. :alert="options.alert"
  69. :rowSelection="options.rowSelection"
  70. showPagination="auto"
  71. >
  72. <!--<span slot="action" slot-scope="record">
  73. <template>
  74. <a @click="handleView(record)">仓库台账</a>
  75. <a-divider type="vertical" />
  76. <a v-if="$auth('store-spare-stores-edit')" @click="handleEdit(record)">出入库详情</a>
  77. </template>
  78. </span>-->
  79. <span slot="delFlag" slot-scope="text">
  80. <badge
  81. :status="DictCache.COLOR.DELFLAG[text]"
  82. :text="delFlagMap[text]" />
  83. </span>
  84. </s-table>
  85. <base-form ref="baseModal" @ok="handleOk"/>
  86. <detail ref="detailModal"/>
  87. </a-card>
  88. </template>
  89. <script>
  90. import { STable, Ellipsis } from '@/components'
  91. import BaseForm from './modules/BaseForm'
  92. import Detail from './modules/Detail'
  93. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  94. import { queryDept,getDeptsAllByParentId } from '@/api/upms/dept'
  95. import { getSpareStoreTotalPage, deleteSpareStores, fetchSpareStore, exportSpareStore } from '@/api/store/sparestore'
  96. export default {
  97. name: 'SpareStoreList',
  98. components: {
  99. STable,
  100. Ellipsis,
  101. BaseForm,
  102. Detail
  103. },
  104. props: {
  105. filter: {
  106. type: Number,
  107. default: -1
  108. }
  109. },
  110. data () {
  111. return {
  112. companyList: {},
  113. projectList: {},
  114. spareTypeTreeData: [],
  115. // 查询参数
  116. queryParam: {
  117. filter: this.filter
  118. },
  119. // 表头
  120. columns: [
  121. {
  122. title: '序号',
  123. dataIndex: 'index',
  124. customRender: (text, record, index) => {
  125. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  126. }
  127. },
  128. {
  129. title: '编号',
  130. dataIndex: 'no'
  131. },
  132. {
  133. title: '备件名称',
  134. dataIndex: 'name'
  135. },
  136. {
  137. title: '规格型号',
  138. dataIndex: 'ggxh'
  139. },
  140. {
  141. title: '计量单位',
  142. dataIndex: 'unit'
  143. },
  144. {
  145. title: '单价',
  146. dataIndex: 'price'
  147. },
  148. {
  149. title: '总库存',
  150. dataIndex: 'totalStock'
  151. }
  152. //{
  153. // title: '创建日期',
  154. // dataIndex: 'createdTime'
  155. //},
  156. //{
  157. // title: '操作',
  158. // key: 'action',
  159. // width: '200px',
  160. // align: 'center',
  161. //scopedSlots: { customRender: 'action' }
  162. // }
  163. ],
  164. // 下拉框map
  165. delFlagMap: {},
  166. // 加载数据方法 必须为 Promise 对象
  167. loadData: parameter => {
  168. parameter = {
  169. ...parameter,
  170. ...this.queryParam,
  171. dataScope: {
  172. }
  173. }
  174. return getSpareStoreTotalPage(Object.assign(parameter, this.queryParam))
  175. .then(res => {
  176. return res.data
  177. })
  178. },
  179. selectedRowKeys: [],
  180. selectedRows: [],
  181. options: {
  182. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  183. rowSelection: {
  184. selectedRowKeys: this.selectedRowKeys,
  185. onChange: this.onSelectChange
  186. }
  187. },
  188. optionAlertShow: false
  189. }
  190. },
  191. created () {
  192. // 下拉框map
  193. this.delFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DELFLAG)
  194. this.tableOption()
  195. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  196. this.companyList = res.data
  197. })
  198. fetchSpareTypeTree({}).then(res => {
  199. this.spareTypeTreeData = res.data
  200. })
  201. },
  202. methods: {
  203. handleCompanyChange(value) {
  204. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU}).then(res => {
  205. this.projectList = res.data
  206. })
  207. },
  208. tableOption () {
  209. if (!this.optionAlertShow) {
  210. this.options = {
  211. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  212. rowSelection: {
  213. selectedRowKeys: this.selectedRowKeys,
  214. onChange: this.onSelectChange,
  215. getCheckboxProps: record => ({
  216. props: {
  217. disabled: false,
  218. name: record.id
  219. }
  220. })
  221. }
  222. }
  223. this.optionAlertShow = true
  224. } else {
  225. this.options = {
  226. alert: false,
  227. rowSelection: null
  228. }
  229. this.optionAlertShow = false
  230. }
  231. },
  232. batchDelete (id) {
  233. let ids = []
  234. if (this.BaseTool.String.isBlank(id)) {
  235. const length = this.selectedRows.length
  236. if (length === 0) {
  237. this.$message.info('请选择要删除的记录')
  238. return
  239. }
  240. ids = this.selectedRows.map(item => item.id)
  241. } else {
  242. ids = [id]
  243. }
  244. deleteSpareStores(ids).then(res => {
  245. this.$message.info('删除成功')
  246. this.handleOk()
  247. this.$refs.table.clearSelected()
  248. })
  249. },
  250. handleEdit (record) {
  251. fetchSpareStore({ id: record.id }).then(res => {
  252. const modal = this.$refs.baseModal
  253. modal.base(res.data)
  254. })
  255. },
  256. handleView (record) {
  257. fetchSpareStore({ id: record.id }).then(res => {
  258. const modal = this.$refs.detailModal
  259. modal.base(res.data)
  260. })
  261. },
  262. handleOk () {
  263. this.$refs.table.refresh()
  264. },
  265. onSelectChange (selectedRowKeys, selectedRows) {
  266. this.selectedRowKeys = selectedRowKeys
  267. this.selectedRows = selectedRows
  268. },
  269. resetSearchForm () {
  270. this.queryParam = {
  271. filter: this.filter
  272. }
  273. this.$refs.table.refresh(true)
  274. },
  275. doExport () {
  276. const parameter = {
  277. ...this.queryParam
  278. }
  279. if(this.queryParam.useCompany == null){
  280. this.$message.error("请先选择分公司")
  281. return
  282. }
  283. if(this.queryParam.useProject == null){
  284. this.$message.error("请先选择项目部")
  285. return
  286. }
  287. exportSpareStore(parameter).then(file => {
  288. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  289. })
  290. },
  291. handleEnter () {
  292. this.$refs.table.refresh(true)
  293. }
  294. }
  295. }
  296. </script>