InStoreForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <div>
  3. <a-card :bordered="false" v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model="queryParam.keyword" placeholder="请输入单号或者发起人" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="12" :sm="24">
  13. <a-form-item label="发起时间区间">
  14. <a-range-picker showTime v-model="createdTime" />
  15. </a-form-item>
  16. </a-col>
  17. <!-- <a-col :md="8" :sm="24">
  18. <a-form-item label="品牌">
  19. <a-input v-model="queryParam.brand" placeholder="模糊查询"/>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="8" :sm="24">
  23. <a-form-item label="类型">
  24. <a-tree-select
  25. style="width: 100%"
  26. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  27. :treeData="spareTypeTreeData"
  28. :treeNodeFilterProp="'title'"
  29. :showSearch="true"
  30. v-model="queryParam.typeIdList"
  31. multiple allowClear
  32. placeholder="请选择"
  33. >
  34. </a-tree-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="8" :sm="24">
  38. <a-form-item label="规格型号">
  39. <a-input v-model="queryParam.ggxh" placeholder="模糊查询"/>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="8" :sm="24">
  43. <a-form-item label="原厂编号">
  44. <a-input v-model="queryParam.initNo" placeholder="模糊查询"/>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="8" :sm="24">
  48. <a-form-item label="生产商">
  49. <a-input v-model="queryParam.producerName" placeholder="名称模糊查询"/>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="8" :sm="24">
  53. <a-form-item label="供应商">
  54. <a-input v-model="queryParam.supplierName" placeholder="名称模糊查询"/>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :md="8" :sm="24">
  58. <a-form-item label="等级">
  59. <a-select v-model="queryParam.level" placeholder="请选择">
  60. <a-select-option
  61. v-for="(label,value) in levelMap"
  62. :key="value"
  63. :label="label"
  64. :value="parseInt(value)">{{ label }}
  65. </a-select-option>
  66. </a-select>
  67. </a-form-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24">
  70. <a-form-item label="用途">
  71. <a-select v-model="queryParam.yt" placeholder="请选择">
  72. <a-select-option
  73. v-for="(label,value) in ytMap"
  74. :key="value"
  75. :label="label"
  76. :value="parseInt(value)">{{ label }}
  77. </a-select-option>
  78. </a-select>
  79. </a-form-item>
  80. </a-col>
  81. <a-col :md="6" :sm="24">
  82. <a-form-item label="是否专用">
  83. <a-select v-model="queryParam.isSpecial" placeholder="请选择">
  84. <a-select-option
  85. v-for="(label,value) in specialMap"
  86. :key="value"
  87. :label="label"
  88. :value="parseInt(value)">{{ label }}
  89. </a-select-option>
  90. </a-select>
  91. </a-form-item>
  92. </a-col>
  93. <a-col :md="6" :sm="24">
  94. <a-form-item label="关联设备">
  95. <a-input v-model="queryParam.model" placeholder="新号/旧号/名称/规格"/>
  96. </a-form-item>
  97. </a-col> -->
  98. <a-col :md="6 || 24" :sm="24">
  99. <span class="table-page-search-submitButtons">
  100. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  101. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  102. </span>
  103. </a-col>
  104. </a-row>
  105. </a-form>
  106. </div>
  107. <div class="table-operator">
  108. <a-button v-if="$auth('store-in-store-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  109. <a-button style="margin-left: 8px" v-if="$auth('store-in-store-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  110. <!--<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('store-in-store-forms-del')">
  111. <a-menu slot="overlay">
  112. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  113. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  114. </a-popconfirm>
  115. </a-menu>
  116. <a-button style="margin-left: 8px">
  117. 批量操作 <a-icon type="down" />
  118. </a-button>
  119. </a-dropdown>-->
  120. </div>
  121. <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">
  122. <span slot="action" slot-scope="record">
  123. <template>
  124. <a @click="handleView(record)">查看</a>
  125. <a-divider v-if="record.status==1" type="vertical" />
  126. <a v-if="$auth('store-in-store-forms-edit') && record.status==1" @click="handleEdit(record)">修改</a>
  127. <a-divider v-if="record.status==1" type="vertical" />
  128. <a-popconfirm v-if="record.status==1" title="是否要入库,入库将更新库存?" @confirm="updateStore(record.id)">
  129. <a>入库</a>
  130. </a-popconfirm>
  131. <a-divider v-if="record.status==1" type="vertical" />
  132. <a-popconfirm v-if="$auth('store-in-store-forms-del')&& record.status==1" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  133. <a>删除</a>
  134. </a-popconfirm>
  135. <a-divider v-if="record.status==2" type="vertical" />
  136. <a-popconfirm v-if="record.status==2" title="是否要撤销?" @confirm="updateStoreBack(record.id)">
  137. <a>撤销</a>
  138. </a-popconfirm>
  139. <a-divider v-if="record.status==2" type="vertical" />
  140. <a v-if="record.status==2" @click="handleStorePrint(record)">打印</a>
  141. </template>
  142. </span>
  143. <span slot="status" slot-scope="text">
  144. <badge :status="DictCache.COLOR.IN_STORE_FORM_STATUS[text]" :text="statusMap[text]" />
  145. </span>
  146. </s-table>
  147. </a-card>
  148. <base-form ref="baseModal" @ok="handleOk" />
  149. <detail ref="detailModal" />
  150. <print-in-store-form ref="baseStorePrintModal" @ok="handleOk" />
  151. </div>
  152. </template>
  153. <script>
  154. import { STable, Ellipsis } from '@/components'
  155. import BaseForm from './modules/BaseForm'
  156. import { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  157. import Detail from './modules/Detail'
  158. import {
  159. getInStoreFormPage,
  160. deleteInStoreForms,
  161. fetchInStoreForm,
  162. updateStore,
  163. updateStoreBack,
  164. exportInStoreForm,
  165. } from '@/api/store/instoreform'
  166. import PrintInStoreForm from '@/views/store/instoreform/modules/PrintInStoreForm'
  167. export default {
  168. name: 'InStoreFormList',
  169. components: {
  170. PrintInStoreForm,
  171. STable,
  172. Ellipsis,
  173. BaseForm,
  174. Detail,
  175. },
  176. props: {
  177. filter: {
  178. type: Number,
  179. default: -1,
  180. },
  181. },
  182. computed: {
  183. createdTime: {
  184. get() {
  185. return [this.queryParam.createdTimeStart, this.queryParam.createdTimeEnd]
  186. },
  187. set(value) {
  188. this.queryParam.createdTimeStart = this.BaseTool.Date.formatter(
  189. value[0],
  190. this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN
  191. )
  192. this.queryParam.createdTimeEnd = this.BaseTool.Date.formatter(
  193. value[1],
  194. this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN
  195. )
  196. },
  197. },
  198. },
  199. data() {
  200. return {
  201. // 查询参数
  202. queryParam: {
  203. filter: this.filter,
  204. createdTimeStart: null,
  205. createdTimeEnd: null,
  206. },
  207. visible: true,
  208. // 表头
  209. columns: [
  210. {
  211. title: '序号',
  212. checked: true,
  213. width: '100px',
  214. dataIndex: 'index',
  215. customRender: (text, record, index) => {
  216. return `${
  217. (this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1
  218. }`
  219. },
  220. },
  221. {
  222. title: '入库单号',
  223. checked: true,
  224. width: 200,
  225. dataIndex: 'inNo',
  226. },
  227. {
  228. title: '入库类型',
  229. checked: true,
  230. dataIndex: 'type',
  231. width: 150,
  232. customRender: (text, record, index) => {
  233. return this.BaseTool.Object.getField(this.typeMap, text)
  234. },
  235. },
  236. {
  237. checked: true,
  238. width: '150px',
  239. title: '入库数量',
  240. dataIndex: 'inNum',
  241. },
  242. {
  243. title: '入库仓库',
  244. checked: true,
  245. width: '150px',
  246. dataIndex: 'storeName',
  247. },
  248. /* {
  249. title: '备件编码',
  250. dataIndex: 'no',
  251. checked: true,
  252. width: '150px'
  253. },
  254. {
  255. title: '品牌',
  256. checked: true,
  257. width: '150px',
  258. dataIndex: 'brand'
  259. },
  260. {
  261. title: '备件名称',
  262. dataIndex: 'name',
  263. checked: true,
  264. width: '150px'
  265. },*/
  266. /* {
  267. title: '规格型号',
  268. checked: true,
  269. width: '150px',
  270. dataIndex: 'ggxh'
  271. },
  272. {
  273. title: '单位',
  274. checked: true,
  275. width: '150px',
  276. dataIndex: 'unit'
  277. },*/
  278. {
  279. title: '发起人',
  280. checked: true,
  281. width: '150px',
  282. dataIndex: 'createdUserName',
  283. },
  284. {
  285. title: '发起时间',
  286. checked: true,
  287. width: '200px',
  288. dataIndex: 'createdTime',
  289. },
  290. /* {
  291. title: '当前库存',
  292. dataIndex: 'currentStock',
  293. checked: true,
  294. width: '100px'
  295. },
  296. {
  297. title: '最高库存',
  298. checked: true,
  299. width: '100px',
  300. dataIndex: 'maxStock'
  301. },
  302. {
  303. title: '最低库存',
  304. checked: true,
  305. width: '100px',
  306. dataIndex: 'minStock'
  307. },
  308. {
  309. title: '等级',
  310. checked: true,
  311. width: '150px',
  312. dataIndex: 'level',
  313. customRender: (text, record, index) => {
  314. return this.BaseTool.Object.getField(this.levelMap, text)
  315. }
  316. },
  317. {
  318. title: '备件类别',
  319. dataIndex: 'typeId',
  320. checked: true,
  321. width: '150px',
  322. customRender: (text, record, index) => {
  323. return record.typeName
  324. }
  325. },
  326. {
  327. title: '备件价值',
  328. dataIndex: 'initialValue',
  329. checked: true,
  330. width: '150px',
  331. customRender: (text, record, index) => {
  332. return this.BaseTool.Amount.formatter(text)
  333. }
  334. },*/
  335. /*{
  336. title: '生产商',
  337. checked: true,
  338. width: '150px',
  339. dataIndex: 'producerId',
  340. customRender: (text, record, index) => {
  341. return record.producerName
  342. }
  343. },
  344. {
  345. title: '用途',
  346. checked: true,
  347. width: '150px',
  348. dataIndex: 'yt',
  349. customRender: (text, record, index) => {
  350. return this.BaseTool.Object.getField(this.ytMap, text)
  351. }
  352. },
  353. {
  354. title: '关联设备号',
  355. checked: true,
  356. width: '150px',
  357. dataIndex: 'sbNo'
  358. },
  359. {
  360. title: '备注',
  361. checked: true,
  362. width: '150px',
  363. dataIndex: 'remark'
  364. },*/
  365. {
  366. title: '状态',
  367. dataIndex: 'status',
  368. checked: true,
  369. fixed: 'right',
  370. width: '100px',
  371. scopedSlots: { customRender: 'status' },
  372. },
  373. // {
  374. // title: '仓库名称',
  375. // dataIndex: 'storeId',
  376. // checked: true,
  377. // width: '150px',
  378. // customRender: (text, record, index) => {
  379. // return record.storeName
  380. // }
  381. // },
  382. {
  383. title: '操作',
  384. fixed: 'right',
  385. checked: true,
  386. key: 'action',
  387. width: '200px',
  388. align: 'center',
  389. scopedSlots: { customRender: 'action' },
  390. },
  391. ],
  392. // 下拉框map
  393. typeMap: {},
  394. levelMap: {},
  395. specialMap: {},
  396. ytMap: {},
  397. unitMap: {},
  398. spareTypeTreeData: [],
  399. // 加载数据方法 必须为 Promise 对象
  400. loadData: (parameter) => {
  401. parameter = {
  402. ...parameter,
  403. ...this.queryParam,
  404. dataScope: {
  405. sortBy: 'desc',
  406. sortName: 'created_time'
  407. }
  408. }
  409. return getInStoreFormPage(Object.assign(parameter, this.queryParam)).then((res) => {
  410. return res.data
  411. })
  412. },
  413. selectedRowKeys: [],
  414. selectedRows: [],
  415. options: {
  416. alert: {
  417. show: true,
  418. clear: () => {
  419. this.selectedRowKeys = []
  420. },
  421. },
  422. rowSelection: {
  423. selectedRowKeys: this.selectedRowKeys,
  424. onChange: this.onSelectChange,
  425. },
  426. },
  427. optionAlertShow: false,
  428. }
  429. },
  430. created() {
  431. // 下拉框map
  432. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_TYPE)
  433. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_STATUS)
  434. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  435. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  436. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  437. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  438. this.tableOption()
  439. fetchSpareTypeTree({}).then((res) => {
  440. this.spareTypeTreeData = res.data
  441. })
  442. },
  443. methods: {
  444. tableOption() {
  445. if (!this.optionAlertShow) {
  446. this.options = {
  447. alert: {
  448. show: true,
  449. clear: () => {
  450. this.selectedRowKeys = []
  451. },
  452. },
  453. rowSelection: {
  454. selectedRowKeys: this.selectedRowKeys,
  455. onChange: this.onSelectChange,
  456. getCheckboxProps: (record) => ({
  457. props: {
  458. disabled: false,
  459. name: record.id,
  460. },
  461. }),
  462. },
  463. }
  464. this.optionAlertShow = true
  465. } else {
  466. this.options = {
  467. alert: false,
  468. rowSelection: null,
  469. }
  470. this.optionAlertShow = false
  471. }
  472. },
  473. batchDelete(id) {
  474. let ids = []
  475. if (this.BaseTool.String.isBlank(id)) {
  476. const length = this.selectedRows.length
  477. if (length === 0) {
  478. this.$message.info('请选择要删除的记录')
  479. return
  480. }
  481. ids = this.selectedRows.map((item) => item.id)
  482. } else {
  483. ids = [id]
  484. }
  485. deleteInStoreForms(ids).then((res) => {
  486. this.$message.info('删除成功')
  487. this.handleOk()
  488. this.$refs.table.clearSelected()
  489. })
  490. },
  491. handleAdd() {
  492. this.visible = false
  493. const modal = this.$refs.baseModal
  494. modal.base()
  495. },
  496. handleEdit(record) {
  497. this.visible = false
  498. fetchInStoreForm({ id: record.id }).then((res) => {
  499. const modal = this.$refs.baseModal
  500. res.data.storeName = record.storeName
  501. modal.base(res.data)
  502. })
  503. },
  504. updateStore(id) {
  505. updateStore({ id: id }).then((res) => {
  506. this.$message.info('入库成功')
  507. this.$refs.table.refresh()
  508. })
  509. },
  510. updateStoreBack(id) {
  511. updateStoreBack({ id: id }).then((res) => {
  512. this.$message.info('撤销成功')
  513. this.$refs.table.refresh()
  514. })
  515. },
  516. handleView(record) {
  517. fetchInStoreForm({ id: record.id }).then((res) => {
  518. const modal = this.$refs.detailModal
  519. res.data.storeName = record.storeName
  520. modal.base(res.data)
  521. })
  522. },
  523. handleOk() {
  524. this.visible = true
  525. this.$refs.table.refresh()
  526. },
  527. onSelectChange(selectedRowKeys, selectedRows) {
  528. this.selectedRowKeys = selectedRowKeys
  529. this.selectedRows = selectedRows
  530. },
  531. resetSearchForm() {
  532. this.queryParam = {
  533. filter: this.filter,
  534. }
  535. this.$refs.table.refresh(true)
  536. },
  537. doExport() {
  538. const parameter = {
  539. ...this.queryParam,
  540. }
  541. exportInStoreForm(parameter).then((file) => {
  542. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  543. })
  544. },
  545. handleEnter() {
  546. this.$refs.table.refresh(true)
  547. },
  548. handleStorePrint(record) {
  549. fetchInStoreForm({ id: record.id }).then((res) => {
  550. const modal = this.$refs.baseStorePrintModal
  551. this.visible = false
  552. modal.base(res.data)
  553. })
  554. },
  555. },
  556. }
  557. </script>