InStoreForm.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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="8" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model.trim="queryParam.keyword" placeholder="请输入单号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="8" :sm="24">
  13. <a-form-item label="入库类型">
  14. <a-select v-model="queryParam.type" placeholder="请选择">
  15. <a-select-option
  16. v-for="(label,value) in typeMap"
  17. :key="value"
  18. :label="label"
  19. :value="parseInt(value)">{{ label }}
  20. </a-select-option>
  21. </a-select>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="8 || 24" :sm="24">
  25. <span class="table-page-search-submitButtons">
  26. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  27. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  28. </span>
  29. </a-col>
  30. </a-row>
  31. </a-form>
  32. </div>
  33. <div class="table-operator" style="margin-bottom: 8px;">
  34. <a-button v-if="$auth('store-in-store-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  35. <a-button style="margin-left: 8px" v-if="$auth('store-in-store-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  36. <!--<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('store-in-store-forms-del')">
  37. <a-menu slot="overlay">
  38. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  39. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  40. </a-popconfirm>
  41. </a-menu>
  42. <a-button style="margin-left: 8px">
  43. 批量操作 <a-icon type="down" />
  44. </a-button>
  45. </a-dropdown>-->
  46. </div>
  47. <s-table
  48. ref="table"
  49. size="default"
  50. rowKey="id"
  51. :columns="columns"
  52. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  53. :data="loadData"
  54. :alert="options.alert"
  55. :rowSelection="options.rowSelection"
  56. showPagination="auto"
  57. >
  58. <span slot="action" slot-scope="record">
  59. <template>
  60. <a @click="handleView(record)">查看</a>
  61. <a-divider v-if="record.status==1" type="vertical" />
  62. <a v-if="$auth('store-in-store-forms-edit') && record.status==1" @click="handleEdit(record)">修改</a>
  63. <a-divider v-if="record.status==1" type="vertical" />
  64. <a-popconfirm v-if="record.status==1" title="是否要入库,入库将更新库存?" @confirm="updateStore(record.id)">
  65. <a>入库</a>
  66. </a-popconfirm>
  67. <a-divider v-if="record.status==1" type="vertical" />
  68. <a-popconfirm v-if="$auth('store-in-store-forms-del')&& record.status==1" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
  69. <a>删除</a>
  70. </a-popconfirm>
  71. <a-divider v-if="record.status==2" type="vertical" />
  72. <a-popconfirm v-if="record.status==2" title="是否要撤销?" @confirm="updateStoreBack(record.id)">
  73. <a>撤销</a>
  74. </a-popconfirm>
  75. <a-divider v-if="record.status==2" type="vertical" />
  76. <a v-if="record.status==2" @click="handleStorePrint(record)">打印</a>
  77. </template>
  78. </span>
  79. <span slot="status" slot-scope="text">
  80. <badge
  81. :status="DictCache.COLOR.IN_STORE_FORM_STATUS[text]"
  82. :text="statusMap[text]" />
  83. </span>
  84. </s-table>
  85. </a-card>
  86. <base-form ref="baseModal" @ok="handleOk"/>
  87. <detail ref="detailModal"/>
  88. <print-in-store-form ref="baseStorePrintModal" @ok="handleOk"/>
  89. </div>
  90. </template>
  91. <script>
  92. import { STable, Ellipsis } from '@/components'
  93. import BaseForm from './modules/BaseForm'
  94. import Detail from './modules/Detail'
  95. import { getInStoreFormPage, deleteInStoreForms, fetchInStoreForm, updateStore, updateStoreBack, exportInStoreForm } from '@/api/store/instoreform'
  96. import PrintInStoreForm from '@/views/store/instoreform/modules/PrintInStoreForm'
  97. export default {
  98. name: 'InStoreFormList',
  99. components: {
  100. PrintInStoreForm,
  101. STable,
  102. Ellipsis,
  103. BaseForm,
  104. Detail
  105. },
  106. props: {
  107. filter: {
  108. type: Number,
  109. default: -1
  110. }
  111. },
  112. data () {
  113. return {
  114. // 查询参数
  115. queryParam: {
  116. filter: this.filter,
  117. ...this.$route.query
  118. },
  119. visible: true,
  120. // 表头
  121. columns: [
  122. {
  123. title: '序号',
  124. dataIndex: 'index',
  125. checked: true,
  126. width: 70,
  127. customRender: (text, record, index) => {
  128. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  129. }
  130. },
  131. {
  132. title: '入库单号',
  133. checked: true,
  134. width: 140,
  135. dataIndex: 'inNo'
  136. },
  137. {
  138. title: '入库类型',
  139. dataIndex: 'type',
  140. checked: true,
  141. width: 140,
  142. customRender: (text, record, index) => {
  143. return this.BaseTool.Object.getField(this.typeMap, text)
  144. }
  145. },
  146. {
  147. title: '总价',
  148. checked: true,
  149. width: 140,
  150. dataIndex: 'totalPrice'
  151. },
  152. {
  153. title: '状态',
  154. checked: true,
  155. width: 140,
  156. dataIndex: 'status',
  157. scopedSlots: { customRender: 'status' }
  158. },
  159. {
  160. title: '创建日期',
  161. checked: true,
  162. width: 140,
  163. dataIndex: 'createdTime'
  164. },
  165. {
  166. title: '仓库',
  167. dataIndex: 'storeId',
  168. checked: true,
  169. width: 140,
  170. customRender: (text, record, index) => {
  171. return record.storeName
  172. }
  173. },
  174. {
  175. title: '操作',
  176. key: 'action',
  177. checked: true,
  178. width: '200px',
  179. fixed: 'right',
  180. align: 'center',
  181. scopedSlots: { customRender: 'action' }
  182. }
  183. ],
  184. // 下拉框map
  185. typeMap: {},
  186. // 加载数据方法 必须为 Promise 对象
  187. loadData: parameter => {
  188. parameter = {
  189. ...parameter,
  190. ...this.queryParam,
  191. dataScope: {
  192. sortBy: 'desc',
  193. sortName: 'update_time'
  194. }
  195. }
  196. return getInStoreFormPage(Object.assign(parameter, this.queryParam))
  197. .then(res => {
  198. return res.data
  199. })
  200. },
  201. selectedRowKeys: [],
  202. selectedRows: [],
  203. options: {
  204. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  205. rowSelection: {
  206. selectedRowKeys: this.selectedRowKeys,
  207. onChange: this.onSelectChange
  208. }
  209. },
  210. optionAlertShow: false
  211. }
  212. },
  213. created () {
  214. // 下拉框map
  215. this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_TYPE)
  216. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.IN_STORE_FORM_STATUS)
  217. this.tableOption()
  218. },
  219. methods: {
  220. tableOption () {
  221. if (!this.optionAlertShow) {
  222. this.options = {
  223. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  224. rowSelection: {
  225. selectedRowKeys: this.selectedRowKeys,
  226. onChange: this.onSelectChange,
  227. getCheckboxProps: record => ({
  228. props: {
  229. disabled: false,
  230. name: record.id
  231. }
  232. })
  233. }
  234. }
  235. this.optionAlertShow = true
  236. } else {
  237. this.options = {
  238. alert: false,
  239. rowSelection: null
  240. }
  241. this.optionAlertShow = false
  242. }
  243. },
  244. batchDelete (id) {
  245. let ids = []
  246. if (this.BaseTool.String.isBlank(id)) {
  247. const length = this.selectedRows.length
  248. if (length === 0) {
  249. this.$message.info('请选择要删除的记录')
  250. return
  251. }
  252. ids = this.selectedRows.map(item => item.id)
  253. } else {
  254. ids = [id]
  255. }
  256. deleteInStoreForms(ids).then(res => {
  257. this.$message.info('删除成功')
  258. this.handleOk()
  259. this.$refs.table.clearSelected()
  260. })
  261. },
  262. handleAdd () {
  263. this.visible = false
  264. const modal = this.$refs.baseModal
  265. modal.base()
  266. },
  267. handleEdit (record) {
  268. this.visible = false
  269. fetchInStoreForm({ id: record.id }).then(res => {
  270. const modal = this.$refs.baseModal
  271. res.data.storeName = record.storeName
  272. modal.base(res.data)
  273. })
  274. },
  275. updateStore (id) {
  276. updateStore({ id: id }).then(res => {
  277. this.$message.info('入库成功')
  278. this.$refs.table.refresh()
  279. })
  280. },
  281. updateStoreBack (id) {
  282. updateStoreBack({ id: id }).then(res => {
  283. this.$message.info('撤销成功')
  284. this.$refs.table.refresh()
  285. })
  286. },
  287. handleView (record) {
  288. fetchInStoreForm({ id: record.id }).then(res => {
  289. const modal = this.$refs.detailModal
  290. res.data.storeName = record.storeName
  291. modal.base(res.data)
  292. })
  293. },
  294. handleOk () {
  295. this.visible = true
  296. this.$refs.table.refresh()
  297. },
  298. onSelectChange (selectedRowKeys, selectedRows) {
  299. this.selectedRowKeys = selectedRowKeys
  300. this.selectedRows = selectedRows
  301. },
  302. resetSearchForm () {
  303. this.queryParam = {
  304. filter: this.filter
  305. }
  306. this.$refs.table.refresh(true)
  307. },
  308. doExport () {
  309. const parameter = {
  310. ...this.queryParam
  311. }
  312. exportInStoreForm(parameter).then(file => {
  313. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  314. })
  315. },
  316. handleEnter () {
  317. this.$refs.table.refresh(true)
  318. },
  319. handleStorePrint (record) {
  320. fetchInStoreForm({ id: record.id }).then(res => {
  321. const modal = this.$refs.baseStorePrintModal
  322. this.visible = false
  323. modal.base(res.data)
  324. })
  325. }
  326. }
  327. }
  328. </script>