list.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehouseAllocationList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" ref="searchForm" :model="queryParam" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <a-range-picker
  10. style="width:100%"
  11. id="warehouseAllocationList-createDate"
  12. :disabledDate="disabledDate"
  13. v-model="createDate"
  14. :format="dateFormat"
  15. :placeholder="['开始时间', '结束时间']"
  16. />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="调出仓库">
  21. <a-select id="warehouseAllocation-basicInfo-outWarehouseSn" allowClear placeholder="请选择调出仓库" v-model="queryParam.outWarehouseSn">
  22. <a-select-option v-for="item in warehouseList" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  23. </a-select>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="调入仓库">
  28. <a-select id="warehouseAllocation-basicInfo-putWarehouseSn" allowClear placeholder="请选择调入仓库" v-model="queryParam.putWarehouseSn">
  29. <a-select-option v-for="item in warehouseList" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  30. </a-select>
  31. </a-form-item>
  32. </a-col>
  33. <template v-if="advanced">
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="单据状态">
  36. <v-select
  37. v-model="queryParam.state"
  38. ref="state"
  39. id="warehouseAllocationList-state"
  40. code="ALLOCATION_WAREHOUSE_STATE"
  41. placeholder="请选择单据状态"
  42. allowClear
  43. ></v-select>
  44. </a-form-item>
  45. </a-col>
  46. </template>
  47. <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
  48. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="warehouseAllocationList-refresh">查询</a-button>
  49. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="warehouseAllocationList-reset">重置</a-button>
  50. <a @click="advanced = !advanced" style="margin-left: 8px">
  51. {{ advanced ? '收起' : '展开' }}
  52. <a-icon :type="advanced ? 'up' : 'down'" />
  53. </a>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. </div>
  58. <!-- 操作按钮 -->
  59. <div class="table-operator"><a-button id="warehouseAllocationList-add" type="primary" class="button-error" @click="openModal = true">新增</a-button></div>
  60. <!-- 列表 -->
  61. <s-table
  62. class="sTable"
  63. ref="table"
  64. size="default"
  65. :rowKey="record => record.id"
  66. :columns="columns"
  67. :data="loadData"
  68. :scroll="{ x: 1480 }"
  69. bordered>
  70. <!-- 单号 -->
  71. <template slot="allocationWarehouseNo" slot-scope="text, record">
  72. <span style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.allocationWarehouseNo }}</span>
  73. </template>
  74. <!-- 状态 -->
  75. <template slot="state" slot-scope="text, record">
  76. {{ text }}
  77. </template>
  78. <!-- 操作 -->
  79. <template slot="action" slot-scope="text, record">
  80. <a-button
  81. v-if="record.stateDictValue == '待审核'"
  82. size="small"
  83. type="primary"
  84. class="button-warning"
  85. @click="handleExamine(record)"
  86. id="warehouseAllocationList-examine-btn">
  87. 审核
  88. </a-button>
  89. <a-button
  90. v-if="record.stateDictValue != '已完结'"
  91. size="small"
  92. type="primary"
  93. class="button-info"
  94. @click="handleEdit(record)"
  95. id="warehouseAllocationList-edit-btn">
  96. 编辑
  97. </a-button>
  98. <a-button
  99. v-if="record.stateDictValue != '已完结'"
  100. size="small"
  101. type="primary"
  102. class="button-error"
  103. @click="handleDel(record)"
  104. id="warehouseAllocationList-del-btn">
  105. 删除
  106. </a-button>
  107. </template>
  108. </s-table>
  109. <!-- 新增/编辑 -->
  110. <basic-info-modal :openModal="openModal" @ok="handleEdit" @close="openModal = false" />
  111. </a-card>
  112. </template>
  113. <script>
  114. import { allocWarehouseList, allocWarehouseAudit, allocWarehouseDelete } from '@/api/allocWarehouse'
  115. import { warehouseAllList } from '@/api/warehouse.js'
  116. import { STable, VSelect } from '@/components'
  117. import basicInfoModal from './basicInfoModal.vue'
  118. import moment from 'moment'
  119. export default {
  120. components: { STable, VSelect, basicInfoModal },
  121. data () {
  122. return {
  123. advanced: false, // 高级搜索 展开/关闭
  124. createDate: undefined, // 创建时间
  125. warehouseList: [], // 仓库列表
  126. queryParam: { // 查询条件
  127. outWarehouseSn: undefined, // 调出仓库
  128. putWarehouseSn: undefined, // 调入仓库
  129. state: undefined // 审核状态
  130. },
  131. disabled: false, // 查询、重置按钮是否可操作
  132. dateFormat: 'YYYY-MM-DD',
  133. columns: [
  134. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  135. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  136. { title: '单号', scopedSlots: { customRender: 'allocationWarehouseNo' }, align: 'center' },
  137. { title: '调出仓库', dataIndex: 'outWarehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  138. { title: '调入仓库', dataIndex: 'putWarehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  139. { title: '总款数', dataIndex: 'productTotalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  140. { title: '总数量', dataIndex: 'productTotalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  141. { title: '总成本', dataIndex: 'productTotalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '状态', dataIndex: 'stateDictValue', width: 100, align: 'center' },
  144. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  145. ],
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. // 创建时间
  150. if (this.createDate && this.createDate.length > 0) {
  151. this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
  152. this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
  153. } else {
  154. this.queryParam.beginDate = undefined
  155. this.queryParam.endDate = undefined
  156. }
  157. return allocWarehouseList(Object.assign(parameter, this.queryParam)).then(res => {
  158. const data = res.data
  159. const no = (data.pageNo - 1) * data.pageSize
  160. for (var i = 0; i < data.list.length; i++) {
  161. data.list[i].no = no + i + 1
  162. }
  163. this.disabled = false
  164. return data
  165. })
  166. },
  167. openModal: false, // 新增编辑 弹框
  168. itemId: '' // 当前品牌id
  169. }
  170. },
  171. methods: {
  172. // 不可选日期
  173. disabledDate (date, dateStrings) {
  174. return date && date.valueOf() > Date.now()
  175. },
  176. // 获取仓库列表
  177. getWarehouseList () {
  178. warehouseAllList({}).then(res => {
  179. console.log(res, '-----仓库----')
  180. if (res.status == 200) {
  181. this.warehouseList = res.data || []
  182. } else {
  183. this.warehouseList = []
  184. }
  185. })
  186. },
  187. // 重置
  188. resetSearchForm () {
  189. this.queryParam.outWarehouseSn = undefined
  190. this.queryParam.putWarehouseSn = undefined
  191. this.queryParam.state = undefined
  192. this.creatDate = undefined
  193. this.$refs.table.refresh(true)
  194. },
  195. // 基本信息 保存
  196. handleOk (data) {
  197. this.$router.push({ path: `/allocationManagement/warehouseAllocation/add` })
  198. },
  199. // 删除
  200. handleDel (row) {
  201. const _this = this
  202. this.$confirm({
  203. title: '提示',
  204. content: '删除后不可恢复,确定要进行删除吗?',
  205. centered: true,
  206. onOk () {
  207. allocWarehouseDelete({ id: row.id }).then(res => {
  208. if (res.status == 200) {
  209. _this.$message.success(res.message)
  210. _this.$refs.table.refresh()
  211. }
  212. })
  213. }
  214. })
  215. },
  216. // 审核
  217. handleExamine (row) {
  218. const _this = this
  219. this.$confirm({
  220. title: '提示',
  221. content: '确认要审核通过吗?',
  222. centered: true,
  223. onOk () {
  224. allocWarehouseAudit({ id: row.id }).then(res => {
  225. if (res.status == 200) {
  226. _this.$message.success(res.message)
  227. _this.$refs.table.refresh()
  228. }
  229. })
  230. }
  231. })
  232. },
  233. // 详情
  234. handleDetail (row) {
  235. this.$router.push({ path: `/allocationManagement/warehouseAllocation/detail/${row.allocationWarehouseSn}` })
  236. },
  237. // 新增/编辑
  238. handleEdit (row) {
  239. this.$router.push({ path: `/allocationManagement/warehouseAllocation/edit/${row.id}/${row.allocationWarehouseSn}` })
  240. }
  241. },
  242. beforeRouteEnter (to, from, next) {
  243. next(vm => {
  244. vm.queryParam.outWarehouseSn = undefined
  245. vm.queryParam.putWarehouseSn = undefined
  246. vm.queryParam.state = undefined
  247. vm.createDate = undefined
  248. vm.getWarehouseList()
  249. })
  250. }
  251. }
  252. </script>