SpareStoreBom.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <a-card :bordered="false">
  3. <a-row :gutter="8" v-show="visible">
  4. <a-col :span="24">
  5. <div class="table-page-search-wrapper">
  6. <a-form layout="inline">
  7. <a-row :gutter="48">
  8. <a-col :md="8" :sm="24">
  9. <a-form-item label="关键字">
  10. <a-input v-model="queryParam.keyword" placeholder="请输入名称/编码" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="8" :sm="24">
  14. <a-form-item label="品牌">
  15. <a-input v-model="queryParam.brand" placeholder="模糊查询" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="8" :sm="24">
  19. <a-form-item label="类型">
  20. <a-tree-select style="width: 100%" :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }" :treeData="spareTypeTreeData" :treeNodeFilterProp="'title'" :showSearch="true" v-model="queryParam.typeId" placeholder="请选择">
  21. </a-tree-select>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="8" :sm="24">
  25. <a-form-item label="规格型号">
  26. <a-input v-model="queryParam.ggxh" placeholder="模糊查询" />
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="8" :sm="24">
  30. <a-form-item label="等级">
  31. <a-select v-model="queryParam.levelList" mode="multiple" placeholder="请选择">
  32. <a-select-option v-for="(label,value) in levelMap" :key="value" :label="label" :value="parseInt(value)">{{ label }}
  33. </a-select-option>
  34. </a-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="6 || 24" :sm="24">
  38. <span class="table-page-search-submitButtons">
  39. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  40. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  41. <a-button style="margin-left: 8px" @click="searchTypeNull">空类型</a-button>
  42. </span>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <div class="table-operator">
  48. <a-button type="primary" icon="plus" @click="handleAdd">更多仓库关联</a-button>
  49. </div>
  50. <s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" :scroll="{x: 1500, y: BaseTool.Constant.scrollY}" :alert="options.alert" :rowSelection="options.rowSelection" showPagination="auto">
  51. <span slot="action" slot-scope="record">
  52. <template>
  53. <!-- <a @click="handleView(record)">查看</a>-->
  54. <a v-if="record.storeId === null || record.storeId === ''" @click="handleRelation(record)">关联仓库</a>
  55. </template>
  56. </span>
  57. </s-table>
  58. </a-col>
  59. </a-row>
  60. <BaseForm ref="baseModal" @ok="handleOk" />
  61. </a-card>
  62. </template>
  63. <script>
  64. import { STable, Ellipsis } from '@/components'
  65. import BaseForm from './modules/BaseForm.vue'
  66. import { getSpareBomPage } from '@/api/sqarepartmanage/sparepartinfo'
  67. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  68. export default {
  69. name: 'SpareStoreBom',
  70. components: {
  71. STable,
  72. Ellipsis,
  73. BaseForm,
  74. },
  75. data() {
  76. return {
  77. // 查询参数
  78. queryParam: {},
  79. confirmLoading: false,
  80. // 表头
  81. columns: [
  82. {
  83. title: '序号',
  84. width: '100px',
  85. dataIndex: 'index',
  86. checked: true,
  87. customRender: (text, record, index) => {
  88. return `${
  89. (this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1
  90. }`
  91. },
  92. },
  93. {
  94. title: '备件编码',
  95. width: '150px',
  96. checked: true,
  97. dataIndex: 'no',
  98. },
  99. {
  100. title: '备件名称',
  101. width: '150px',
  102. checked: true,
  103. dataIndex: 'name',
  104. },
  105. {
  106. title: '备件类别',
  107. dataIndex: 'typeName',
  108. checked: true,
  109. width: '150px',
  110. },
  111. {
  112. title: '品牌',
  113. width: '150px',
  114. checked: true,
  115. dataIndex: 'brand',
  116. },
  117. {
  118. title: '规格型号',
  119. width: '150px',
  120. checked: true,
  121. dataIndex: 'ggxh',
  122. },
  123. {
  124. title: '等级',
  125. checked: true,
  126. width: '150px',
  127. dataIndex: 'level',
  128. customRender: (text, record, index) => {
  129. return this.BaseTool.Object.getField(this.levelMap, text)
  130. },
  131. },
  132. {
  133. title: '备件价值',
  134. width: '150px',
  135. checked: true,
  136. dataIndex: 'initialValue',
  137. },
  138. {
  139. title: '操作',
  140. checked: true,
  141. width: '120',
  142. fixed: 'right',
  143. key: 'action',
  144. align: 'center',
  145. scopedSlots: { customRender: 'action' },
  146. },
  147. ],
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: (parameter) => {
  150. parameter = {
  151. ...parameter,
  152. ...this.queryParam,
  153. bomFlag: 0,
  154. dataScope: {
  155. sortBy: 'desc',
  156. sortName: 'info.created_time',
  157. },
  158. }
  159. return getSpareBomPage(Object.assign(parameter, this.queryParam)).then((res) => {
  160. return res.data
  161. })
  162. },
  163. selectedRowKeys: [],
  164. selectedRows: [],
  165. expandedKeys: [],
  166. selectedKeys: [],
  167. levelMap: {},
  168. id: null,
  169. visible: true,
  170. spareTypeTreeData: [],
  171. options: {
  172. alert: {
  173. show: true,
  174. clear: () => {
  175. this.selectedRowKeys = []
  176. },
  177. },
  178. rowSelection: {
  179. selectedRowKeys: this.selectedRowKeys,
  180. onChange: this.onSelectChange,
  181. },
  182. },
  183. optionAlertShow: false,
  184. }
  185. },
  186. created() {
  187. // 下拉框map
  188. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  189. this.tableOption()
  190. fetchSpareTypeTree({}).then((res) => {
  191. this.spareTypeTreeData = res.data
  192. })
  193. },
  194. methods: {
  195. tableOption() {
  196. if (!this.optionAlertShow) {
  197. this.options = {
  198. alert: {
  199. show: true,
  200. clear: () => {
  201. this.selectedRowKeys = []
  202. },
  203. },
  204. rowSelection: {
  205. selectedRowKeys: this.selectedRowKeys,
  206. onChange: this.onSelectChange,
  207. getCheckboxProps: (record) => ({
  208. props: {
  209. disabled: false,
  210. name: record.id,
  211. },
  212. }),
  213. },
  214. }
  215. this.optionAlertShow = true
  216. } else {
  217. this.options = {
  218. alert: false,
  219. rowSelection: null,
  220. }
  221. this.optionAlertShow = false
  222. }
  223. },
  224. handleAdd () {
  225. this.$refs.baseModal.base()
  226. },
  227. handleRelation(record) {
  228. this.$refs.baseModal.base(record)
  229. },
  230. handleOk() {
  231. this.visible = true
  232. this.$refs.table.refresh()
  233. },
  234. onSelectChange(selectedRowKeys, selectedRows) {
  235. this.selectedRowKeys = selectedRowKeys
  236. this.selectedRows = selectedRows
  237. },
  238. resetSearchForm() {
  239. this.queryParam = {}
  240. this.$refs.table.refresh(true)
  241. },
  242. onSelect: function (selectedKeys, info) {
  243. this.selectedKeys = selectedKeys
  244. this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
  245. this.$refs.table.refresh(true)
  246. },
  247. onExpand(expandedKeys) {
  248. this.expandedKeys = expandedKeys
  249. this.autoExpandParent = false
  250. },
  251. searchTypeNull() {
  252. this.queryParam.searchType = true
  253. this.$refs.table.refresh(true)
  254. },
  255. },
  256. }
  257. </script>