SpareStoreTotal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  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.keyword" placeholder="请输入名称/编码"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="品牌">
  13. <a-input v-model="queryParam.brand" placeholder="模糊查询"/>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :md="8" :sm="24">
  17. <a-form-item label="类型">
  18. <a-tree-select
  19. style="width: 100%"
  20. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  21. :treeData="spareTypeTreeData"
  22. :treeNodeFilterProp="'title'"
  23. :showSearch="true"
  24. v-model="queryParam.typeId"
  25. placeholder="请选择"
  26. >
  27. </a-tree-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="8" :sm="24">
  31. <a-form-item label="规格型号">
  32. <a-input v-model="queryParam.ggxh" placeholder="模糊查询"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="8" :sm="24">
  36. <a-form-item label="原厂编号">
  37. <a-input v-model="queryParam.initNo" placeholder="模糊查询"/>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="8" :sm="24">
  41. <a-form-item label="生产商">
  42. <a-input v-model="queryParam.producerName" placeholder="名称模糊查询"/>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="8" :sm="24">
  46. <a-form-item label="供应商">
  47. <a-input v-model="queryParam.supplierName" placeholder="名称模糊查询"/>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="8" :sm="24">
  51. <a-form-item label="等级">
  52. <a-select v-model="queryParam.level" placeholder="请选择">
  53. <a-select-option
  54. v-for="(label,value) in levelMap"
  55. :key="value"
  56. :label="label"
  57. :value="parseInt(value)">{{ label }}
  58. </a-select-option>
  59. </a-select>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-item label="用途">
  64. <a-select v-model="queryParam.yt" placeholder="请选择">
  65. <a-select-option
  66. v-for="(label,value) in ytMap"
  67. :key="value"
  68. :label="label"
  69. :value="parseInt(value)">{{ label }}
  70. </a-select-option>
  71. </a-select>
  72. </a-form-item>
  73. </a-col>
  74. <a-col :md="6" :sm="24">
  75. <a-form-item label="是否专用">
  76. <a-select v-model="queryParam.isSpecial" placeholder="请选择">
  77. <a-select-option
  78. v-for="(label,value) in specialMap"
  79. :key="value"
  80. :label="label"
  81. :value="parseInt(value)">{{ label }}
  82. </a-select-option>
  83. </a-select>
  84. </a-form-item>
  85. </a-col>
  86. <a-col :md="6" :sm="24">
  87. <a-form-item label="关联设备">
  88. <a-input v-model="queryParam.model" placeholder="新号/旧号/名称/规格"/>
  89. </a-form-item>
  90. </a-col>
  91. <a-col :md="6 || 24" :sm="24">
  92. <span class="table-page-search-submitButtons">
  93. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  94. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  95. <!-- <a-button style="margin-left: 8px" @click="searchTypeNull">空类型</a-button> -->
  96. </span>
  97. </a-col>
  98. </a-row>
  99. </a-form>
  100. </div>
  101. <div class="table-operator">
  102. <!--<a-button v-if="$auth('store-spare-stores-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
  103. <a-button style="margin-left: 8px" v-if="$auth('store-spare-stores-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  104. </div>
  105. <s-table
  106. ref="table"
  107. size="default"
  108. rowKey="id"
  109. :columns="columns"
  110. :data="loadData"
  111. :alert="options.alert"
  112. :scroll="{x: 1500, y: BaseTool.Constant.scrollY}"
  113. :rowSelection="options.rowSelection"
  114. showPagination="auto"
  115. >
  116. <span slot="action" slot-scope="record">
  117. <template>
  118. <a v-if="record.warnStatus != 1" @click="handleUpdateStatus(record, 1)">待处理</a>
  119. <a-divider type="vertical" />
  120. <a v-if="record.warnStatus != 2" @click="handleUpdateStatus(record, 2)">询价中</a>
  121. <a-divider type="vertical" />
  122. <a v-if="record.warnStatus != 3"@click="handleUpdateStatus(record, 3)">采购中</a>
  123. <a-divider type="vertical" />
  124. <a v-if="record.warnStatus != 0" @click="handleUpdateStatus(record, 0)">正常</a>
  125. </template>
  126. </span>
  127. <span slot="status" slot-scope="text">
  128. <badge
  129. :status="DictCache.COLOR.SPARE_WARN_STATUS[text]"
  130. :text="warnStatusMap[text]" />
  131. </span>
  132. </s-table>
  133. <base-form ref="baseModal" @ok="handleOk"/>
  134. <detail ref="detailModal"/>
  135. </a-card>
  136. </template>
  137. <script>
  138. import { STable, Ellipsis } from '@/components'
  139. import BaseForm from './modules/BaseForm'
  140. import Detail from './modules/Detail'
  141. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  142. import { getSparePartInfoPage, updateSparePartInfoWarnStatus, exportSparePartInfo } from '@/api/sqarepartmanage/sparepartinfo'
  143. import { queryDept, getDeptsAllByParentId } from '@/api/upms/dept'
  144. export default {
  145. name: 'SpareStoreTotal',
  146. components: {
  147. STable,
  148. Ellipsis,
  149. BaseForm,
  150. Detail
  151. },
  152. props: {
  153. filter: {
  154. type: Number,
  155. default: -1
  156. },
  157. warnStatusList: {
  158. type: Array,
  159. default: null
  160. },
  161. forecastStatusList: {
  162. type: Array,
  163. default: null
  164. }
  165. },
  166. data () {
  167. return {
  168. companyList: {},
  169. projectList: {},
  170. warnStatusMap: {},
  171. ytMap: {},
  172. specialMap: {},
  173. levelMap: {},
  174. spareTypeTreeData: [],
  175. // 查询参数
  176. queryParam: {
  177. filter: this.filter,
  178. warnStatusList: this.warnStatusList,
  179. forecastStatusList: this.forecastStatusList
  180. },
  181. // 表头
  182. columns: [
  183. {
  184. title: '序号',
  185. width: '100px',
  186. dataIndex: 'index',
  187. checked: true,
  188. customRender: (text, record, index) => {
  189. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  190. }
  191. },
  192. {
  193. title: '备件编码',
  194. width: '150px',
  195. checked: true,
  196. dataIndex: 'no'
  197. },
  198. {
  199. title: '品牌',
  200. width: '150px',
  201. checked: true,
  202. dataIndex: 'brand'
  203. },
  204. {
  205. title: '备件名称',
  206. width: '150px',
  207. checked: true,
  208. dataIndex: 'name'
  209. },
  210. {
  211. title: '规格型号',
  212. width: '150px',
  213. checked: true,
  214. dataIndex: 'ggxh'
  215. },
  216. {
  217. title: '单位',
  218. width: '150px',
  219. checked: true,
  220. dataIndex: 'unit'
  221. },
  222. {
  223. title: '库位',
  224. width: '150px',
  225. checked: true,
  226. dataIndex: 'storeName'
  227. },
  228. {
  229. title: '当前库存',
  230. width: '150px',
  231. checked: true,
  232. dataIndex: 'totalStock',
  233. customRender: (text, record, index) => {
  234. if (text == null) {
  235. return 0
  236. } else {
  237. return text
  238. }
  239. }
  240. },
  241. {
  242. title: '最高库存',
  243. width: '150px',
  244. checked: true,
  245. dataIndex: 'maxStock'
  246. },
  247. {
  248. title: '最低库存',
  249. width: '150px',
  250. checked: true,
  251. dataIndex: 'minStock'
  252. },
  253. {
  254. title: '等级',
  255. checked: true,
  256. width: '150px',
  257. dataIndex: 'level',
  258. customRender: (text, record, index) => {
  259. return this.BaseTool.Object.getField(this.levelMap, text)
  260. }
  261. },
  262. {
  263. title: '备件价值',
  264. width: '150px',
  265. checked: true,
  266. dataIndex: 'price'
  267. },
  268. {
  269. title: '备件类别',
  270. dataIndex: 'typeName',
  271. checked: true,
  272. width: '150px'
  273. },
  274. {
  275. title: '生产商',
  276. checked: true,
  277. width: '150px',
  278. dataIndex: 'producerId',
  279. customRender: (text, record, index) => {
  280. return record.producerName
  281. }
  282. },
  283. {
  284. title: '用途',
  285. checked: true,
  286. width: '150px',
  287. dataIndex: 'yt',
  288. customRender: (text, record, index) => {
  289. return this.BaseTool.Object.getField(this.ytMap, text)
  290. }
  291. },
  292. {
  293. title: '关联设备号',
  294. checked: true,
  295. width: '150px',
  296. dataIndex: 'sbNo'
  297. },
  298. {
  299. title: '备注',
  300. checked: true,
  301. width: '150px',
  302. dataIndex: 'remark'
  303. },
  304. {
  305. title: '状态',
  306. checked: true,
  307. dataIndex: 'warnStatus',
  308. scopedSlots: { customRender: 'status' }
  309. },
  310. {
  311. title: '操作',
  312. checked: true,
  313. key: 'action',
  314. fixed: 'right',
  315. width: '200px',
  316. align: 'center',
  317. scopedSlots: { customRender: 'action' }
  318. }
  319. ],
  320. // 下拉框map
  321. delFlagMap: {},
  322. // 加载数据方法 必须为 Promise 对象
  323. loadData: parameter => {
  324. parameter = {
  325. ...parameter,
  326. ...this.queryParam,
  327. dataScope: {
  328. }
  329. }
  330. return getSparePartInfoPage(Object.assign(parameter, this.queryParam))
  331. .then(res => {
  332. return res.data
  333. })
  334. },
  335. selectedRowKeys: [],
  336. selectedRows: [],
  337. options: {
  338. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  339. rowSelection: {
  340. selectedRowKeys: this.selectedRowKeys,
  341. onChange: this.onSelectChange
  342. }
  343. },
  344. optionAlertShow: false
  345. }
  346. },
  347. created () {
  348. // 下拉框map
  349. this.warnStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_WARN_STATUS)
  350. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  351. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  352. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  353. this.tableOption()
  354. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  355. this.companyList = res.data
  356. })
  357. fetchSpareTypeTree({}).then(res => {
  358. this.spareTypeTreeData = res.data
  359. })
  360. },
  361. methods: {
  362. handleCompanyChange (value) {
  363. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU }).then(res => {
  364. this.projectList = res.data
  365. })
  366. },
  367. tableOption () {
  368. if (!this.optionAlertShow) {
  369. this.options = {
  370. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  371. rowSelection: {
  372. selectedRowKeys: this.selectedRowKeys,
  373. onChange: this.onSelectChange,
  374. getCheckboxProps: record => ({
  375. props: {
  376. disabled: false,
  377. name: record.id
  378. }
  379. })
  380. }
  381. }
  382. this.optionAlertShow = true
  383. } else {
  384. this.options = {
  385. alert: false,
  386. rowSelection: null
  387. }
  388. this.optionAlertShow = false
  389. }
  390. },
  391. handleUpdateStatus (record, warnStatus) {
  392. const parameter = {}
  393. parameter.id = record.id
  394. parameter.warnStatus = warnStatus
  395. parameter.type = 1
  396. updateSparePartInfoWarnStatus(parameter)
  397. .then(() => {
  398. this.handleOk()
  399. }).catch(() => {
  400. this.confirmLoading = false
  401. })
  402. },
  403. handleOk () {
  404. this.$refs.table.refresh()
  405. },
  406. onSelectChange (selectedRowKeys, selectedRows) {
  407. this.selectedRowKeys = selectedRowKeys
  408. this.selectedRows = selectedRows
  409. },
  410. resetSearchForm () {
  411. this.queryParam = {
  412. filter: this.filter,
  413. warnStatusList: this.warnStatusList,
  414. forecastStatusList: this.forecastStatusList
  415. }
  416. this.$refs.table.refresh(true)
  417. },
  418. doExport () {
  419. const parameter = {
  420. ...this.queryParam
  421. }
  422. exportSparePartInfo(parameter).then(file => {
  423. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  424. })
  425. },
  426. handleEnter () {
  427. this.$refs.table.refresh(true)
  428. }
  429. }
  430. }
  431. </script>