list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" 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_sparePartsBatchAudit')"
  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 fixPagination"
  45. ref="table"
  46. :style="{ height: tableHeight+84.5+'px' }"
  47. size="small"
  48. :row-selection="rowSelection"
  49. :rowKey="(record) => record.sparePartsSn"
  50. :columns="columns"
  51. :data="loadData"
  52. :scroll="{ x: 1390, y: tableHeight }"
  53. :defaultLoadData="false"
  54. bordered>
  55. <!-- 入库单号 -->
  56. <template slot="sparePartsNo" slot-scope="text, record">
  57. <span :class="$hasPermissions('B_sparePartsDetail')?'active':'common'" @click="handleDetail(record)">{{ record.sparePartsNo }}</span>
  58. </template>
  59. <!-- 操作 -->
  60. <template slot="action" slot-scope="text, record">
  61. <a-button
  62. size="small"
  63. type="link"
  64. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsAudit')"
  65. class="button-warning"
  66. @click="handleAudit(record)"
  67. id="allocateBillList-examine-btn">审核</a-button>
  68. <a-button
  69. size="small"
  70. type="link"
  71. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsEdit')"
  72. @click="handleEdit(record)"
  73. class="button-info"
  74. id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
  75. <a-button
  76. size="small"
  77. type="link"
  78. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_sparePartsDel')"
  79. @click="handleDel(record)"
  80. class="button-error"
  81. id="bulkWarehousingOrderList-del-btn">删除</a-button>
  82. <span v-if="!(record.state == 'WAIT_AUDIT'&&($hasPermissions('B_sparePartsEdit') || $hasPermissions('B_sparePartsDel') || $hasPermissions('B_sparePartsAudit')))">--</span>
  83. </template>
  84. </s-table>
  85. </a-spin>
  86. <!-- 选择基本信息弹框 -->
  87. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  88. <sparePartsDetailModal :openModal="openDetailModal" :itemSn="itemSn" @close="closeDetailModal" />
  89. </a-card>
  90. </template>
  91. <script>
  92. import { STable, VSelect } from '@/components'
  93. import basicInfoModal from './basicInfoModal.vue'
  94. import sparePartsDetailModal from './detailModal.vue'
  95. import { sparePartsList, sparePartsDelete, sparePartsAudit } from '@/api/spareParts'
  96. export default {
  97. components: { STable, VSelect, basicInfoModal, sparePartsDetailModal },
  98. data () {
  99. return {
  100. spinning: false,
  101. disabled: false, // 查询、重置按钮是否可操作
  102. openModal: false, // 基本信息弹框是否显示
  103. tableHeight: 0,
  104. // 查询参数
  105. queryParam: {
  106. productCode: '',
  107. relationNo: ''
  108. },
  109. // 表头
  110. columns: [
  111. { title: '创建时间', dataIndex: 'createDate', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '入库单号', scopedSlots: { customRender: 'sparePartsNo' }, width: 150, align: 'center' },
  113. { title: '商户名称', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  114. { title: '入库数量', dataIndex: 'productTotalQty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  115. { title: '入库成本', dataIndex: 'productTotalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  116. { title: '入库类型', dataIndex: 'sparePartsTypeDictValue', width: 70, align: 'center', customRender: function (text) { return text || '--' } },
  117. { title: '关联单号', dataIndex: 'relationNo', width: 70, align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '金蝶单号', dataIndex: 'kingdeeNo', width: 150, align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '状态', dataIndex: 'stateDictValue', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  120. { title: '备注', dataIndex: 'remark', width: 150, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  121. { title: '操作', scopedSlots: { customRender: 'action' }, width: 140, align: 'center', fixed: 'right' }
  122. ],
  123. selectedRowKeys: [], // Check here to configure the default column
  124. selectedRows: [],
  125. loading: false,
  126. // 加载数据方法 必须为 Promise 对象
  127. loadData: parameter => {
  128. this.disabled = true
  129. this.spinning = true
  130. return sparePartsList(Object.assign(parameter, this.queryParam)).then(res => {
  131. const data = res.data
  132. const no = (data.pageNo - 1) * data.pageSize
  133. for (var i = 0; i < data.list.length; i++) {
  134. data.list[i].no = no + i + 1
  135. }
  136. this.disabled = false
  137. this.spinning = false
  138. return data
  139. })
  140. },
  141. openDetailModal: false,
  142. itemSn: null
  143. }
  144. },
  145. computed: {
  146. hasSelected () {
  147. return this.selectedRowKeys.length > 0
  148. },
  149. rowSelection () {
  150. if (this.$hasPermissions('B_sparePartsBatchAudit')) {
  151. return {
  152. selectedRowKeys: this.selectedRowKeys,
  153. onChange: (selectedRowKeys, selectedRows) => {
  154. this.onChange(selectedRowKeys, selectedRows)
  155. },
  156. onSelect: (record, selected, selectedRows, nativeEvent) => {
  157. this.onSelectChange(record, selected, selectedRows, nativeEvent)
  158. },
  159. onSelectAll: (selected, selectedRows, changeRows) => {
  160. this.onSelectAllChange(selected, selectedRows, changeRows)
  161. },
  162. getCheckboxProps: record => ({
  163. props: {
  164. disabled: record.state != 'WAIT_AUDIT'
  165. }
  166. })
  167. }
  168. } else {
  169. return null
  170. }
  171. }
  172. },
  173. methods: {
  174. onChange (selectedRowKeys, selectedRows) {
  175. this.selectedRowKeys = selectedRowKeys
  176. },
  177. onSelectChange (record, selected, selectedRows, nativeEvent) {
  178. if (selected) { // 选择
  179. this.selectedRows.push(record)
  180. } else { // 取消
  181. this.selectedRows = selectedRows
  182. }
  183. },
  184. // 本页全选/取消全选
  185. onSelectAllChange (selected, selectedRows, changeRows) {
  186. const _this = this
  187. if (selected) { // 选择
  188. this.selectedRows = [...this.selectedRows, ...changeRows]
  189. } else { // 取消
  190. const arrId = []
  191. this.selectedRows.map((item, index) => {
  192. this.selectedRows.map((subItem, ind) => {
  193. if (item.sparePartsSn == subItem.sparePartsSn) {
  194. arrId.push(index)
  195. }
  196. })
  197. })
  198. arrId.map((item, index) => {
  199. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  200. })
  201. }
  202. },
  203. // 新增
  204. handleAdd () {
  205. this.openModal = true
  206. },
  207. // 基本信息 保存
  208. handleOk (row) {
  209. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsSn}` })
  210. },
  211. // 编辑
  212. handleEdit (row) {
  213. this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsSn}` })
  214. },
  215. // 详情
  216. handleDetail (row) {
  217. if (!this.$hasPermissions('B_sparePartsDetail')) { return }
  218. this.itemSn = row.sparePartsSn
  219. this.openDetailModal = true
  220. },
  221. // 关闭弹框
  222. closeDetailModal () {
  223. this.itemSn = null
  224. this.openDetailModal = false
  225. },
  226. // 删除
  227. handleDel (row) {
  228. const _this = this
  229. this.$confirm({
  230. title: '提示',
  231. content: '删除后不可恢复,确定要进行删除吗?',
  232. centered: true,
  233. onOk () {
  234. _this.spinning = true
  235. sparePartsDelete({ sn: row.sparePartsSn }).then(res => {
  236. if (res.status == 200) {
  237. _this.$message.success(res.message)
  238. _this.$refs.table.refresh()
  239. _this.spinning = false
  240. } else {
  241. _this.spinning = false
  242. }
  243. })
  244. }
  245. })
  246. },
  247. // 重置
  248. resetSearchForm () {
  249. this.queryParam.productCode = ''
  250. this.queryParam.relationNo = ''
  251. this.$refs.table.refresh(true)
  252. },
  253. // 单条审核
  254. handleAudit (row, isBatch) {
  255. const _this = this
  256. let content = ''
  257. let params = []
  258. if (isBatch) { // 批量
  259. content = '确认要批量审核吗?'
  260. params = row
  261. } else { // 单条
  262. content = '确认要审核通过吗?'
  263. params = [row.sparePartsSn]
  264. }
  265. this.$confirm({
  266. title: '提示',
  267. content: content,
  268. centered: true,
  269. onOk () {
  270. _this.spinning = true
  271. sparePartsAudit(params).then(res => {
  272. if (res.status == 200) {
  273. _this.selectedRowKeys = []
  274. _this.selectedRows = []
  275. _this.$message.success(res.message)
  276. _this.$refs.table.refresh()
  277. _this.spinning = false
  278. } else {
  279. _this.spinning = false
  280. }
  281. })
  282. }
  283. })
  284. },
  285. // 批量审核
  286. handleBatchAudit () {
  287. if (this.selectedRowKeys.length < 1) {
  288. this.$message.warning('请在列表勾选后再进行批量操作!')
  289. return
  290. }
  291. this.handleAudit(this.selectedRowKeys, 'batch')
  292. },
  293. pageInit () {
  294. const _this = this
  295. this.$nextTick(() => { // 页面渲染完成后的回调
  296. _this.setTableH()
  297. })
  298. this.openModal = false
  299. this.openDetailModal = false
  300. this.itemSn = null
  301. },
  302. setTableH () {
  303. const tableSearchH = this.$refs.tableSearch.offsetHeight
  304. this.tableHeight = window.innerHeight - tableSearchH - 235
  305. }
  306. },
  307. mounted () {
  308. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  309. this.pageInit()
  310. this.resetSearchForm()
  311. }
  312. },
  313. activated () {
  314. // 如果是新页签打开,则重置当前页面
  315. if (this.$store.state.app.isNewTab) {
  316. this.pageInit()
  317. this.resetSearchForm()
  318. }
  319. },
  320. beforeRouteEnter (to, from, next) {
  321. next(vm => {})
  322. }
  323. }
  324. </script>
  325. <style lang="less">
  326. .bulkWarehousingOrderList-wrap{
  327. .active{
  328. color: #ed1c24;
  329. cursor: pointer;
  330. }
  331. .common{
  332. color: rgba(0, 0, 0, 0.65);
  333. }
  334. }
  335. </style>