list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <a-card size="small" :bordered="false" class="chainTransferOutList-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. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="审核时间">
  15. <rangeDate ref="auditRangeDate" v-model="auditTime" @change="auditDateChange" />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="出库时间">
  20. <rangeDate ref="outWareRangeDate" v-model="outWareTime" @change="outWareDateChange" />
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="连锁调出单号">
  25. <a-input id="chainTransferOutList-allocationLinkageOutNo" v-model.trim="queryParam.allocationLinkageOutNo" allowClear placeholder="请输入连锁调出单号"/>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="调往对象">
  31. <getTenantList id="chainTransferOutList-putTenantSn" type="out" placeholder="请选择调往对象" v-model="queryParam.putTenantSn"></getTenantList>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="调出产品类型">
  36. <v-select
  37. v-model="queryParam.allocationType"
  38. ref="allocationType"
  39. id="chainTransferOutList-allocationType"
  40. code="ALLOCATION_LINKAGE_PRODUCT_TYPE"
  41. placeholder="请选择调出产品类型"
  42. allowClear></v-select>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="业务状态">
  47. <v-select
  48. v-model="queryParam.state"
  49. ref="state"
  50. id="chainTransferOutList-state"
  51. code="ALLOCATION_LINKAGE_OUT_STATUS"
  52. placeholder="请选择业务状态"
  53. allowClear></v-select>
  54. </a-form-item>
  55. </a-col>
  56. <a-col :md="6" :sm="24">
  57. <a-form-item label="财务状态">
  58. <v-select
  59. v-model="queryParam.settleState"
  60. ref="settleState"
  61. id="chainTransferOutList-settleState"
  62. code="FINANCIAL_STATUS"
  63. placeholder="请选择财务状态"
  64. allowClear></v-select>
  65. </a-form-item>
  66. </a-col>
  67. </template>
  68. <a-col :md="24" :sm="24" style="margin-bottom: 10px;text-align: center;">
  69. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chainTransferOutList-refresh">查询</a-button>
  70. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="chainTransferOutList-reset">重置</a-button>
  71. <a-button
  72. type="primary"
  73. class="button-warning"
  74. v-if="$hasPermissions('B_allocLinkageOutExport')"
  75. @click="handleExport"
  76. :disabled="disabled"
  77. :loading="exportLoading"
  78. id="chainTransferOutList-export">导出</a-button>
  79. <a @click="advanced=!advanced" style="margin-left: 8px">
  80. {{ advanced ? '收起' : '展开' }}
  81. <a-icon :type="advanced ? 'up' : 'down'"/>
  82. </a>
  83. </a-col>
  84. </a-row>
  85. </a-form>
  86. </div>
  87. <!-- 操作按钮 -->
  88. <div class="table-operator">
  89. <a-button id="chainTransferOutList-add" v-if="$hasPermissions('B_allocLinkageOutNew')" type="primary" class="button-error" @click="openModal=true">新增</a-button>
  90. </div>
  91. <!-- 统计 -->
  92. <a-alert type="info" style="margin-bottom:10px">
  93. <div slot="message">
  94. 总款数: <strong>{{ countData&&(countData.productTotalCategory || countData.productTotalCategory==0) ? countData.productTotalCategory : '--' }}</strong> ,
  95. 总数量: <strong>{{ countData&&(countData.productTotalQty || countData.productTotalQty==0) ? countData.productTotalQty : '--' }}</strong>
  96. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  97. ,总成本: <strong>{{ countData&&(countData.productTotalCost || countData.productTotalCost==0) ? toThousands(countData.productTotalCost,2) : '--' }}</strong>
  98. </div>
  99. </div>
  100. </a-alert>
  101. <!-- 列表 -->
  102. <s-table
  103. class="sTable fixPagination"
  104. ref="table"
  105. :style="{ height: tableHeight+84.5+'px' }"
  106. size="small"
  107. :rowKey="(record) => record.id"
  108. :columns="columns"
  109. :data="loadData"
  110. :scroll="{ y: tableHeight }"
  111. :defaultLoadData="false"
  112. bordered>
  113. <!-- 连锁调出单号 -->
  114. <template slot="allocationLinkageOutNo" slot-scope="text, record">
  115. <span class="table-td-link" v-if="$hasPermissions('B_allocLinkageOutDetail')" @click="handleDetail(record)">{{ record.allocationLinkageOutNo }}</span>
  116. <span v-else>{{ record.allocationLinkageOutNo }}</span>
  117. </template>
  118. <!-- 审核 -->
  119. <template slot="audit" slot-scope="text, record">
  120. <stateIcon :title="record.stateDictValue" :state="record.state == 'FINISH'||record.state == 'WAIT_OUT_WAREHOUSE'?'1':'2'"></stateIcon>
  121. </template>
  122. <!-- 结算 -->
  123. <template slot="financial" slot-scope="text, record">
  124. <stateIcon :title="record.settleStateDictValue" :state="record.settleState == 'FINISH'?'1':'2'"></stateIcon>
  125. </template>
  126. <!-- 出库 -->
  127. <template slot="waitOut" slot-scope="text, record">
  128. <stateIcon :state="record.state == 'FINISH'?'1':'2'"></stateIcon>
  129. </template>
  130. <!-- 操作 -->
  131. <template slot="action" slot-scope="text, record">
  132. <a-button
  133. size="small"
  134. type="link"
  135. v-if="record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocLinkageOutAudit')"
  136. class="button-primary"
  137. @click="handleExamine(record)"
  138. id="chainTransferOutList-examine-btn">审核</a-button>
  139. <a-button
  140. size="small"
  141. type="link"
  142. v-if="(record.state == 'WAIT_SUBMIT' || record.state == 'WAIT_AUDIT') &&$hasPermissions('B_allocLinkageOutEdit')"
  143. class="button-primary"
  144. @click="handleEdit(record)"
  145. id="chainTransferOutList-edit-btn">编辑</a-button>
  146. <a-button
  147. size="small"
  148. type="link"
  149. v-if="record.state == 'WAIT_OUT_WAREHOUSE'&&$hasPermissions('B_allocLinkageOutStock')"
  150. class="button-primary"
  151. @click="handleOut(record)"
  152. id="chainTransferOutList-out-btn">出库</a-button>
  153. <a-button
  154. size="small"
  155. type="link"
  156. v-if="(record.state == 'WAIT_SUBMIT' || record.state == 'WAIT_AUDIT' || record.state == 'WAIT_OUT_WAREHOUSE') &&$hasPermissions('B_allocLinkageOutDel')"
  157. class="button-error"
  158. @click="handleDel(record)"
  159. id="chainTransferOutList-del-btn">删除</a-button>
  160. <span v-if="(record.state != 'WAIT_SUBMIT' && record.state != 'WAIT_AUDIT' && record.state != 'WAIT_OUT_WAREHOUSE')|| (!(record.state == 'WAIT_AUDIT'&&$hasPermissions('B_allocLinkageOutAudit')) && !((record.state == 'WAIT_SUBMIT' || record.state == 'WAIT_AUDIT') &&$hasPermissions('B_allocLinkageOutEdit')) && !(record.state == 'WAIT_OUT_WAREHOUSE'&&$hasPermissions('B_allocLinkageOutStock')))">--</span>
  161. </template>
  162. </s-table>
  163. </a-spin>
  164. <!-- 新增/编辑 -->
  165. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  166. </a-card>
  167. </template>
  168. <script>
  169. import { commonMixin } from '@/utils/mixin'
  170. import { STable, VSelect } from '@/components'
  171. import rangeDate from '@/views/common/rangeDate.vue'
  172. import basicInfoModal from './basicInfoModal.vue'
  173. import stateIcon from '@/views/common/stateIcon'
  174. import getDate from '@/libs/getDate.js'
  175. import getTenantList from '@/views/common/getTenantList.js'
  176. import { downloadExcel } from '@/libs/JGPrint.js'
  177. import { allocLinkageOutList, allocLinkageAudit, allocLinkageOutDel, allocLinkageOutStock, allocLinkageOutQueryCount, allocLinkageOutExport } from '@/api/allocLinkageOut'
  178. export default {
  179. name: 'AllocLinkageOutList',
  180. components: { STable, VSelect, basicInfoModal, rangeDate, stateIcon, getTenantList },
  181. mixins: [commonMixin],
  182. data () {
  183. return {
  184. spinning: false,
  185. exportLoading: false,
  186. tableHeight: 0,
  187. advanced: true, // 高级搜索 展开/关闭
  188. time: [
  189. getDate.getCurrMonthDays().starttime,
  190. getDate.getCurrMonthDays().endtime
  191. ],
  192. auditTime: [],
  193. outWareTime: [],
  194. queryParam: { // 查询条件
  195. beginDate: getDate.getCurrMonthDays().starttime,
  196. endDate: getDate.getCurrMonthDays().endtime,
  197. auditBeginDate: '',
  198. auditEndDate: '',
  199. outWarehouseBeginDate: '',
  200. outWarehouseEndDate: '',
  201. allocationLinkageOutNo: undefined, // 连锁调出单号
  202. putTenantSn: undefined, // 调往对象
  203. allocationType: undefined, // 调出产品类型
  204. state: undefined, // 业务状态
  205. settleState: undefined
  206. },
  207. disabled: false, // 查询、重置按钮是否可操作
  208. // 加载数据方法 必须为 Promise 对象
  209. loadData: parameter => {
  210. this.disabled = true
  211. this.spinning = true
  212. const params = Object.assign(parameter, this.queryParam)
  213. return allocLinkageOutList(params).then(res => {
  214. let data
  215. if (res.status == 200) {
  216. data = res.data
  217. this.getCount(params)
  218. const no = (data.pageNo - 1) * data.pageSize
  219. for (var i = 0; i < data.list.length; i++) {
  220. data.list[i].no = no + i + 1
  221. }
  222. this.disabled = false
  223. }
  224. this.spinning = false
  225. return data
  226. })
  227. },
  228. openModal: false, // 新增编辑 弹框
  229. itemId: '', // 当前品牌id
  230. countData: null // 统计
  231. }
  232. },
  233. computed: {
  234. columns () {
  235. const _this = this
  236. const arr = [
  237. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  238. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '连锁调出单号', scopedSlots: { customRender: 'allocationLinkageOutNo' }, width: '16%', align: 'center' },
  240. { title: '调往对象', dataIndex: 'putTenantName', width: '17%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  241. { title: '总款数', dataIndex: 'productTotalCategory', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  242. { title: '总数量', dataIndex: 'productTotalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  243. // { title: '总成本', dataIndex: 'productTotalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  244. { title: '审核时间', dataIndex: 'auditTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '调拨类型', dataIndex: 'allocationTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  246. { title: '业务状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  247. // { title: '财务状态', dataIndex: 'settleStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  248. { title: '审核', scopedSlots: { customRender: 'audit' }, width: '3%', align: 'center' },
  249. { title: '出库', scopedSlots: { customRender: 'waitOut' }, width: '3%', align: 'center' },
  250. { title: '收款', scopedSlots: { customRender: 'financial' }, width: '3%', align: 'center' },
  251. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  252. ]
  253. if (this.$hasPermissions('M_ShowAllCost')) {
  254. arr.splice(6, 0, { title: '总成本', dataIndex: 'productTotalCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
  255. }
  256. return arr
  257. }
  258. },
  259. methods: {
  260. // 统计
  261. getCount (params) {
  262. allocLinkageOutQueryCount(params).then(res => {
  263. if (res.status == 200) {
  264. this.countData = res.data
  265. } else {
  266. this.countData = null
  267. }
  268. })
  269. },
  270. // 时间 change
  271. dateChange (date) {
  272. this.queryParam.beginDate = date[0]
  273. this.queryParam.endDate = date[1]
  274. },
  275. auditDateChange (date) {
  276. this.queryParam.auditBeginDate = date[0]
  277. this.queryParam.auditEndDate = date[1]
  278. },
  279. outWareDateChange (date) {
  280. this.queryParam.outWarehouseBeginDate = date[0]
  281. this.queryParam.outWarehouseEndDate = date[1]
  282. },
  283. // 导出
  284. handleExport () {
  285. const _this = this
  286. const params = this.queryParam
  287. params.showCost = _this.$hasPermissions('M_ShowAllCost') ? 1 : 0
  288. _this.exportLoading = true
  289. _this.spinning = true
  290. allocLinkageOutExport(params).then(res => {
  291. this.exportLoading = false
  292. _this.spinning = false
  293. if (res.type == 'application/json') {
  294. var reader = new FileReader()
  295. reader.addEventListener('loadend', function () {
  296. const obj = JSON.parse(reader.result)
  297. _this.$notification.error({
  298. message: '提示',
  299. description: obj.message
  300. })
  301. })
  302. reader.readAsText(res)
  303. } else {
  304. downloadExcel(res, '连锁调出列表')
  305. }
  306. })
  307. },
  308. // 重置
  309. resetSearchForm () {
  310. this.resetData()
  311. this.$refs.table.refresh(true)
  312. },
  313. // 重置数据
  314. resetData (flag) {
  315. this.$refs.rangeDate.resetDate(flag ? '' : this.time)
  316. this.queryParam.beginDate = flag ? '' : getDate.getCurrMonthDays().starttime
  317. this.queryParam.endDate = flag ? '' : getDate.getCurrMonthDays().endtime
  318. this.$refs.auditRangeDate.resetDate('')
  319. this.queryParam.auditBeginDate = ''
  320. this.queryParam.auditEndDate = ''
  321. this.$refs.outWareRangeDate.resetDate('')
  322. this.queryParam.outWarehouseBeginDate = ''
  323. this.queryParam.outWarehouseEndDate = ''
  324. this.queryParam.allocationLinkageOutNo = undefined
  325. this.queryParam.putTenantSn = undefined
  326. this.queryParam.allocationType = undefined
  327. this.queryParam.state = undefined
  328. this.queryParam.settleState = undefined
  329. if (!flag) {
  330. this.setIsHomeNav(this.$route.name, null)
  331. }
  332. },
  333. // 基本信息 保存
  334. handleOk (data) {
  335. this.resetData()
  336. this.$router.push({ path: `/allocationManagement/chainTransferOut/add/${data.id}/${data.allocationLinkageOutSn}` })
  337. },
  338. // 删除
  339. handleDel (row) {
  340. const _this = this
  341. this.$confirm({
  342. title: '提示',
  343. content: '删除后不可恢复,确定要进行删除吗?',
  344. centered: true,
  345. onOk () {
  346. _this.spinning = true
  347. allocLinkageOutDel({ sn: row.allocationLinkageOutSn }).then(res => {
  348. if (res.status == 200) {
  349. _this.$message.success(res.message)
  350. _this.$refs.table.refresh()
  351. _this.spinning = false
  352. } else {
  353. _this.spinning = false
  354. }
  355. })
  356. }
  357. })
  358. },
  359. // 出库
  360. handleOut (row) {
  361. const _this = this
  362. this.$confirm({
  363. title: '提示',
  364. content: '确认要出库吗?',
  365. centered: true,
  366. onOk () {
  367. _this.spinning = true
  368. allocLinkageOutStock({ sn: row.allocationLinkageOutSn }).then(res => {
  369. if (res.status == 200) {
  370. _this.$message.success(res.message)
  371. _this.$refs.table.refresh()
  372. _this.spinning = false
  373. } else {
  374. _this.spinning = false
  375. }
  376. })
  377. }
  378. })
  379. },
  380. // 审核
  381. handleExamine (row) {
  382. const _this = this
  383. this.$confirm({
  384. title: '提示',
  385. content: '确认要审核通过吗?',
  386. centered: true,
  387. onOk () {
  388. _this.spinning = true
  389. allocLinkageAudit({ sn: row.allocationLinkageOutSn }).then(res => {
  390. if (res.status == 200) {
  391. _this.$message.success(res.message)
  392. _this.$refs.table.refresh()
  393. _this.spinning = false
  394. } else {
  395. _this.spinning = false
  396. }
  397. })
  398. }
  399. })
  400. },
  401. // 详情
  402. handleDetail (row) {
  403. this.$router.push({ path: `/allocationManagement/chainTransferOut/detail/${row.allocationLinkageOutSn}` })
  404. },
  405. // 新增/编辑
  406. handleEdit (row) {
  407. this.$router.push({ path: `/allocationManagement/chainTransferOut/edit/${row.id}/${row.allocationLinkageOutSn}` })
  408. },
  409. pageInit () {
  410. const _this = this
  411. this.$nextTick(() => { // 页面渲染完成后的回调
  412. _this.setTableH()
  413. })
  414. this.openModal = false
  415. // 是否打开的页签
  416. const a = this.$store.state.app.isNewTab
  417. // 是否要刷新列表
  418. const b = this.$store.state.app.updateList
  419. // 是否从首页点击进入
  420. const isHomeNav = this.getIsHomeNav()[this.$route.name]
  421. console.log(a, b, this.getIsHomeNav(), isHomeNav, this.$route.name)
  422. // 从首页进入,判断式新建还式待办查询
  423. if (isHomeNav) {
  424. // 新增
  425. if (isHomeNav.type == 'new') {
  426. this.resetSearchForm()
  427. this.openModal = true
  428. }
  429. // 待办
  430. if (isHomeNav.type == 'todo') {
  431. this.resetData(true)
  432. this.queryParam = Object.assign(this.queryParam, isHomeNav.pageParams)
  433. this.$refs.rangeDate.resetDate([this.queryParam.beginDate, this.queryParam.endDate])
  434. this.$refs.table.refresh(true)
  435. }
  436. } else {
  437. // 如果是新页签打开,则重置当前页面
  438. if (a && !b) {
  439. this.resetSearchForm()
  440. }
  441. }
  442. // 仅刷新列表,不重置页面
  443. if (b || a == b) {
  444. this.$refs.table.refresh()
  445. }
  446. },
  447. setTableH () {
  448. const tableSearchH = this.$refs.tableSearch.offsetHeight
  449. this.tableHeight = window.innerHeight - tableSearchH - 273
  450. }
  451. },
  452. watch: {
  453. advanced (newValue, oldValue) {
  454. const _this = this
  455. this.$nextTick(() => { // 页面渲染完成后的回调
  456. _this.setTableH()
  457. })
  458. },
  459. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  460. this.setTableH()
  461. }
  462. },
  463. mounted () {},
  464. activated () {
  465. this.pageInit()
  466. },
  467. beforeRouteEnter (to, from, next) {
  468. next(vm => {})
  469. }
  470. }
  471. </script>