list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocateBillList-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. <a-input id="allocateBillList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入调往对象"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="调拨类型">
  20. <AllocateType id="allocateBillList-allocateTypeSn" v-model="queryParam.allocateTypeSn"></AllocateType>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="业务状态">
  26. <v-select
  27. v-model="queryParam.state"
  28. ref="state"
  29. id="allocateBillList-state"
  30. code="ALLOCATE_STATUS"
  31. placeholder="请选择业务状态"
  32. allowClear
  33. ></v-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="调拨单号">
  38. <a-input id="allocateBillList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  39. </a-form-item>
  40. </a-col>
  41. </template>
  42. <a-col :md="6" :sm="24">
  43. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="allocateBillList-refresh">查询</a-button>
  44. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocateBillList-reset">重置</a-button>
  45. <a-button
  46. style="margin-left: 5px"
  47. type="primary"
  48. class="button-warning"
  49. v-if="$hasPermissions('B_transferOut_export')"
  50. @click="handleExport"
  51. :disabled="disabled"
  52. :loading="exportLoading"
  53. id="allocateBillList-export">导出</a-button>
  54. <a @click="advanced=!advanced" style="margin-left: 5px">
  55. {{ advanced ? '收起' : '展开' }}
  56. <a-icon :type="advanced ? 'up' : 'down'"/>
  57. </a>
  58. </a-col>
  59. </a-row>
  60. </a-form>
  61. </div>
  62. <!-- 操作按钮 -->
  63. <div class="table-operator">
  64. <a-button v-if="$hasPermissions('B_transferOut_add')" id="allocateBillList-add" type="primary" class="button-error" @click="openModal=true">新增</a-button>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable fixPagination"
  69. ref="table"
  70. :style="{ height: tableHeight+84.5+'px' }"
  71. size="small"
  72. :rowKey="(record) => record.id"
  73. :columns="columns"
  74. :data="loadData"
  75. :defaultLoadData="false"
  76. :scroll="{ y: tableHeight }"
  77. bordered>
  78. <!-- 单号 -->
  79. <template slot="allocateNo" slot-scope="text, record">
  80. <a-button v-if="$hasPermissions('M_transferOut_detail')" size="small" type="link" class="button-info" @click="handleDetail(record)">{{ record.allocateNo }}</a-button>
  81. <span v-else>{{ record.allocateNo }}</span>
  82. </template>
  83. <!-- 起止时间 -->
  84. <template slot="promoDate" slot-scope="text, record">
  85. <span v-if="record.promoStartDate || record.promoEndDate">{{ record.promoStartDate }} ~ {{ record.promoEndDate }}</span>
  86. <span v-else>--</span>
  87. </template>
  88. <!-- 操作 -->
  89. <template slot="action" slot-scope="text, record">
  90. <a-button
  91. size="small"
  92. type="link"
  93. v-if="record.state == 'WAIT_AUDIT' && $hasPermissions('B_transferOut_audit')"
  94. class="button-warning"
  95. @click="handleExamine(record)"
  96. id="allocateBillList-examine-btn">审核</a-button>
  97. <a-button
  98. size="small"
  99. type="link"
  100. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')) && $hasPermissions('M_transferOut_edit')"
  101. class="button-info"
  102. @click="handleEdit(record)"
  103. id="allocateBillList-edit-btn">编辑</a-button>
  104. <a-button
  105. size="small"
  106. type="link"
  107. v-if="((record.state == 'WAIT_SUBMIT') || (record.state == 'WAIT_AUDIT') || (record.state == 'AUDIT_REJECT')) && $hasPermissions('B_transferOut_del')"
  108. class="button-error"
  109. @click="handleDel(record)"
  110. id="allocateBillList-del-btn">删除</a-button>
  111. <span v-if="((record.state != 'WAIT_SUBMIT') && (record.state != 'WAIT_AUDIT') && (record.state != 'AUDIT_REJECT'))||(!$hasPermissions('B_transferOut_audit') && !$hasPermissions('M_transferOut_edit') && !$hasPermissions('B_transferOut_del'))">--</span>
  112. </template>
  113. </s-table>
  114. </a-spin>
  115. <!-- 新增 -->
  116. <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
  117. <!-- 审核 -->
  118. <auditModal :openModal="visibleAudit" :spinning="spinningAudit" @close="visibleAudit=false" @ok="auditOrder('WAIT_OUT_WAREHOUSE')" @fail="auditOrder('AUDIT_REJECT')" />
  119. </a-card>
  120. </template>
  121. <script>
  122. import { commonMixin } from '@/utils/mixin'
  123. import moment from 'moment'
  124. import getDate from '@/libs/getDate.js'
  125. import { STable, VSelect } from '@/components'
  126. import basicInfoModal from './basicInfoModal.vue'
  127. import rangeDate from '@/views/common/rangeDate.vue'
  128. import auditModal from '@/views/common/auditModal.vue'
  129. import { allocateBillList, allocateBillDel, allocateBillAudit, allocateBillExport } from '@/api/allocateBill'
  130. import AllocateType from '@/views/common/allocateType.js'
  131. import { hdExportExcel } from '@/libs/exportExcel'
  132. export default {
  133. name: 'TransferOutList',
  134. mixins: [commonMixin],
  135. components: { STable, VSelect, basicInfoModal, rangeDate, auditModal, AllocateType },
  136. data () {
  137. return {
  138. spinning: false,
  139. advanced: true, // 高级搜索 展开/关闭
  140. tableHeight: 0,
  141. time: [
  142. moment(getDate.getThreeMonthDays().starttime, 'YYYY-MM-DD'),
  143. moment(getDate.getCurrMonthDays().endtime, 'YYYY-MM-DD')
  144. ],
  145. queryParam: { // 查询条件
  146. beginDate: getDate.getThreeMonthDays().starttime,
  147. endDate: getDate.getCurrMonthDays().endtime,
  148. targetName: '', // 调往对象
  149. allocateTypeSn: undefined, // 调拨类型
  150. state: undefined, // 业务状态
  151. allocateNo: '' // 调拨单号
  152. },
  153. disabled: false, // 查询、重置按钮是否可操作
  154. exportLoading: false,
  155. // 加载数据方法 必须为 Promise 对象
  156. loadData: parameter => {
  157. this.disabled = true
  158. this.spinning = true
  159. return allocateBillList(Object.assign(parameter, this.queryParam)).then(res => {
  160. let data
  161. if (res.status == 200) {
  162. data = res.data
  163. const no = (data.pageNo - 1) * data.pageSize
  164. for (var i = 0; i < data.list.length; i++) {
  165. data.list[i].no = no + i + 1
  166. }
  167. this.disabled = false
  168. }
  169. this.spinning = false
  170. return data
  171. })
  172. },
  173. visibleAudit: false,
  174. auditInfo: null,
  175. spinningAudit: false,
  176. openModal: false // 新增编辑 弹框
  177. }
  178. },
  179. computed: {
  180. columns () {
  181. const arr = [
  182. { title: '序号', dataIndex: 'no', width: '3.5%', align: 'center' },
  183. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  184. { title: '调拨单号', scopedSlots: { customRender: 'allocateNo' }, align: 'center', width: '13.5%' },
  185. { title: '起止时间', scopedSlots: { customRender: 'promoDate' }, align: 'center', width: '8%' },
  186. { title: '调往对象', dataIndex: 'targetName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  187. { title: '客户类型', dataIndex: 'dealerLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  188. // { title: '总成本', dataIndex: 'totalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. { title: '总数量', dataIndex: 'totalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  190. // { title: '总售价', dataIndex: 'totalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  191. { title: '审核时间', dataIndex: 'auditTime', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  192. { title: '调拨类型', dataIndex: 'allocateTypeName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '业务状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '打印状态', dataIndex: 'printStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '打印次数', dataIndex: 'printCount', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  196. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  197. ]
  198. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  199. arr.splice(6, 0, { title: '总成本', dataIndex: 'totalCost', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  200. }
  201. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  202. const ind = this.$hasPermissions('B_isShowCost') ? 8 : 7
  203. arr.splice(ind, 0, { title: '总售价', dataIndex: 'totalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  204. }
  205. return arr
  206. }
  207. },
  208. methods: {
  209. // 创建时间 change
  210. dateChange (date) {
  211. this.queryParam.beginDate = date[0]
  212. this.queryParam.endDate = date[1]
  213. },
  214. // 重置
  215. resetSearchForm () {
  216. this.$refs.rangeDate.resetDate(this.time)
  217. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  218. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  219. this.queryParam.targetName = ''
  220. this.queryParam.allocateTypeSn = undefined
  221. this.queryParam.state = undefined
  222. this.queryParam.allocateNo = ''
  223. this.$refs.table.refresh(true)
  224. },
  225. // 基本信息 保存
  226. handleOk (data) {
  227. this.$router.push({ path: `/allocationManagement/transferOut/add/${data.allocateSn}/${data.dealerLevel}` })
  228. },
  229. // 删除
  230. handleDel (row) {
  231. const _this = this
  232. this.$confirm({
  233. title: '提示',
  234. content: '删除后不可恢复,确定要进行删除吗?',
  235. centered: true,
  236. onOk () {
  237. _this.spinning = true
  238. allocateBillDel({ sn: row.allocateSn }).then(res => {
  239. if (res.status == 200) {
  240. _this.$message.success(res.message)
  241. _this.$refs.table.refresh()
  242. _this.spinning = false
  243. } else {
  244. _this.spinning = false
  245. }
  246. })
  247. }
  248. })
  249. },
  250. // 审核
  251. handleExamine (row) {
  252. this.auditInfo = row
  253. this.visibleAudit = true
  254. },
  255. // 审核
  256. auditOrder (state) {
  257. const _this = this
  258. _this.spinningAudit = true
  259. allocateBillAudit({ sn: this.auditInfo.allocateSn, state: state }).then(res => {
  260. if (res.status == 200) {
  261. _this.visibleAudit = false
  262. _this.$message.success(res.message)
  263. _this.$refs.table.refresh()
  264. _this.spinningAudit = false
  265. } else {
  266. _this.visibleAudit = false
  267. _this.spinningAudit = false
  268. }
  269. })
  270. },
  271. // 详情
  272. handleDetail (row) {
  273. if (this.$hasPermissions('M_transferOut_detail')) {
  274. this.$router.push({ path: `/allocationManagement/transferOut/detail/${row.allocateSn}` })
  275. }
  276. },
  277. // 编辑
  278. handleEdit (row) {
  279. this.$router.push({ path: `/allocationManagement/transferOut/edit/${row.allocateSn}/${row.dealerLevel}` })
  280. },
  281. // 导出
  282. handleExport () {
  283. const _this = this
  284. const params = this.queryParam
  285. this.exportLoading = true
  286. this.spinning = true
  287. hdExportExcel(allocateBillExport, params, '调拨列表', function () {
  288. _this.exportLoading = false
  289. _this.spinning = false
  290. })
  291. },
  292. pageInit () {
  293. const _this = this
  294. this.$nextTick(() => { // 页面渲染完成后的回调
  295. _this.setTableH()
  296. })
  297. this.openModal = false
  298. },
  299. setTableH () {
  300. const tableSearchH = this.$refs.tableSearch.offsetHeight
  301. this.tableHeight = window.innerHeight - tableSearchH - 238
  302. }
  303. },
  304. watch: {
  305. advanced (newValue, oldValue) {
  306. const _this = this
  307. this.$nextTick(() => { // 页面渲染完成后的回调
  308. _this.setTableH()
  309. })
  310. },
  311. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  312. this.setTableH()
  313. }
  314. },
  315. mounted () {
  316. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  317. this.pageInit()
  318. this.resetSearchForm()
  319. }
  320. },
  321. activated () {
  322. // 如果是新页签打开,则重置当前页面
  323. if (this.$store.state.app.isNewTab) {
  324. this.pageInit()
  325. this.resetSearchForm()
  326. }
  327. // 仅刷新列表,不重置页面
  328. if (this.$store.state.app.updateList) {
  329. this.pageInit()
  330. this.$refs.table.refresh()
  331. }
  332. },
  333. beforeRouteEnter (to, from, next) {
  334. next(vm => {})
  335. }
  336. }
  337. </script>
  338. <style lang="less">
  339. .active{
  340. color: #ed1c24;
  341. cursor: pointer;
  342. }
  343. .common{
  344. color: rgba(0, 0, 0);
  345. }
  346. </style>