list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="产品编码">
  10. <a-input id="bulkWarehousingOrderList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="关联单号">
  15. <a-input id="bulkWarehousingOrderList-relationNo" v-model.trim="queryParam.relationNo" allowClear placeholder="请输入关联单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <span class="table-page-search-submitButtons">
  20. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderList-refresh">查询</a-button>
  21. <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="bulkWarehousingOrderList-reset">重置</a-button>
  22. </span>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <!-- 操作按钮 -->
  28. <div class="table-operator">
  29. <a-button v-if="$hasPermissions('B_sparePartsNew')" id="bulkWarehousingOrderList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  30. <a-button
  31. v-if="$hasPermissions('B_sparePartsAudit')"
  32. id="bulkWarehousingOrderList-batchAudit"
  33. type="primary"
  34. class="button-warning"
  35. :loading="loading"
  36. @click="handleBatchAudit"
  37. style="margin: 0 15px;">批量审核</a-button>
  38. <span style="margin-left: 8px">
  39. <template v-if="hasSelected">{{ `已选 ${selectedRowKeys.length} 项` }}</template>
  40. </span>
  41. </div>
  42. <!-- 列表 -->
  43. <s-table
  44. class="sTable"
  45. ref="table"
  46. size="small"
  47. :row-selection="rowSelection"
  48. :rowKey="(record) => record.sparePartsSn"
  49. :columns="columns"
  50. :data="loadData"
  51. :scroll="{ x: 1960, y: tableHeight }"
  52. bordered>
  53. <!-- 入库单号 -->
  54. <template slot="sparePartsNo" slot-scope="text, record">
  55. <span :class="$hasPermissions('B_sparePartsDetail')?'active':'common'" @click="handleDetail(record)">{{ record.sparePartsNo }}</span>
  56. </template>
  57. <!-- 操作 -->
  58. <template slot="action" slot-scope="text, record">
  59. <a-button
  60. size="small"
  61. type="link"
  62. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsEdit')"
  63. @click="handleEdit(record)"
  64. class="button-info"
  65. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  66. <a-button
  67. size="small"
  68. type="link"
  69. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsDel')"
  70. @click="handleDel(record)"
  71. class="button-error"
  72. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  73. <span v-if="record.state != 'WAIT_AUDIT'||(!$hasPermissions('B_sparePartsEdit') && !$hasPermissions('B_sparePartsDel'))">--</span>
  74. </template>
  75. </s-table>
  76. </a-spin>
  77. <!-- 选择基本信息弹框 -->
  78. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  79. <sparePartsDetailModal :openModal="openDetailModal" :itemSn="itemSn" @close="closeDetailModal" />
  80. </a-card>
  81. </template>
  82. <script>
  83. import { STable, VSelect } from '@/components'
  84. import basicInfoModal from './basicInfoModal.vue'
  85. import sparePartsDetailModal from './detailModal.vue'
  86. import { sparePartsList, sparePartsDelete, sparePartsAudit } from '@/api/spareParts'
  87. export default {
  88. components: { STable, VSelect, basicInfoModal, sparePartsDetailModal },
  89. data () {
  90. return {
  91. spinning: false,
  92. disabled: false, // 查询、重置按钮是否可操作
  93. openModal: false, // 基本信息弹框是否显示
  94. tableHeight: 0,
  95. // 查询参数
  96. queryParam: {
  97. productCode: '',
  98. relationNo: ''
  99. },
  100. // 表头
  101. columns: [
  102. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '入库单号', scopedSlots: { customRender: 'sparePartsNo' }, width: 220, align: 'center' },
  104. { title: '商户名称', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  105. { title: '入库数量', dataIndex: 'productTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '入库成本', dataIndex: 'productTotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  107. { title: '入库类型', dataIndex: 'sparePartsTypeDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '关联单号', dataIndex: 'relationNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '金蝶单号', dataIndex: 'kingdeeNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '状态', dataIndex: 'stateDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '备注', dataIndex: 'remark', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  112. { title: '操作', scopedSlots: { customRender: 'action' }, width: 130, align: 'center', fixed: 'right' }
  113. ],
  114. selectedRowKeys: [], // Check here to configure the default column
  115. selectedRows: [],
  116. loading: false,
  117. // 加载数据方法 必须为 Promise 对象
  118. loadData: parameter => {
  119. this.disabled = true
  120. if (this.tableHeight == 0) {
  121. this.tableHeight = window.innerHeight - 285
  122. }
  123. return sparePartsList(Object.assign(parameter, this.queryParam)).then(res => {
  124. const data = res.data
  125. const no = (data.pageNo - 1) * data.pageSize
  126. for (var i = 0; i < data.list.length; i++) {
  127. data.list[i].no = no + i + 1
  128. }
  129. this.disabled = false
  130. return data
  131. })
  132. },
  133. openDetailModal: false,
  134. itemSn: null
  135. }
  136. },
  137. computed: {
  138. hasSelected () {
  139. return this.selectedRowKeys.length > 0
  140. },
  141. rowSelection () {
  142. if (this.$hasPermissions('B_sparePartsAudit')) {
  143. return {
  144. selectedRowKeys: this.selectedRowKeys,
  145. onChange: (selectedRowKeys, selectedRows) => {
  146. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
  147. this.onSelectChange(selectedRowKeys)
  148. },
  149. getCheckboxProps: record => ({
  150. props: {
  151. disabled: record.state != 'WAIT_AUDIT'
  152. }
  153. })
  154. }
  155. } else {
  156. return null
  157. }
  158. }
  159. },
  160. methods: {
  161. onSelectChange (selectedRowKeys, selectedRows) {
  162. this.selectedRowKeys = selectedRowKeys
  163. this.selectedRows = selectedRows
  164. },
  165. // 新增
  166. handleAdd () {
  167. this.openModal = true
  168. },
  169. // 基本信息 保存
  170. handleOk (row) {
  171. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsSn}` })
  172. },
  173. // 编辑
  174. handleEdit (row) {
  175. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsSn}` })
  176. },
  177. // 详情
  178. handleDetail (row) {
  179. if (!this.$hasPermissions('B_sparePartsDetail')) { return }
  180. this.itemSn = row.sparePartsSn
  181. this.openDetailModal = true
  182. },
  183. // 关闭弹框
  184. closeDetailModal () {
  185. this.itemSn = null
  186. this.openDetailModal = false
  187. },
  188. // 删除
  189. handleDel (row) {
  190. const _this = this
  191. this.$confirm({
  192. title: '提示',
  193. content: '删除后不可恢复,确定要进行删除吗?',
  194. centered: true,
  195. onOk () {
  196. _this.spinning = true
  197. sparePartsDelete({ sn: row.sparePartsSn }).then(res => {
  198. if (res.status == 200) {
  199. _this.$message.success(res.message)
  200. _this.$refs.table.refresh()
  201. _this.spinning = false
  202. } else {
  203. _this.spinning = false
  204. }
  205. })
  206. }
  207. })
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam.productCode = ''
  212. this.queryParam.relationNo = ''
  213. this.$refs.table.refresh(true)
  214. },
  215. // 批量审核
  216. handleBatchAudit () {
  217. const _this = this
  218. if (_this.selectedRowKeys.length < 1) {
  219. _this.$message.warning('请在列表勾选后再进行批量操作!')
  220. return
  221. }
  222. this.$confirm({
  223. title: '提示',
  224. content: '确认要批量审核吗?',
  225. centered: true,
  226. onOk () {
  227. _this.spinning = true
  228. sparePartsAudit(_this.selectedRowKeys).then(res => {
  229. if (res.status == 200) {
  230. _this.selectedRowKeys = []
  231. _this.selectedRows = []
  232. _this.$message.success(res.message)
  233. _this.$refs.table.refresh()
  234. _this.spinning = false
  235. } else {
  236. _this.spinning = false
  237. }
  238. })
  239. }
  240. })
  241. }
  242. },
  243. beforeRouteEnter (to, from, next) {
  244. next(vm => {
  245. vm.openModal = false
  246. vm.openDetailModal = false
  247. vm.itemSn = null
  248. })
  249. }
  250. }
  251. </script>
  252. <style lang="less">
  253. .bulkWarehousingOrderList-wrap{
  254. .active{
  255. color: #ed1c24;
  256. cursor: pointer;
  257. }
  258. .common{
  259. color: rgba(0, 0, 0, 0.65);
  260. }
  261. }
  262. </style>