list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <a-card size="small" :bordered="false" class="urgentItemsOffsetList-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 id="urgentItemsOffsetList-creatDate" 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. <custList id="urgentItemsOffsetList-custList" ref="custList" v-model="queryParam.buyerNameCurrent"></custList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="关联单号">
  20. <a-input id="urgentItemsOffsetList-bizBillNo" v-model.trim="queryParam.bizBillNo" allowClear placeholder="请输入销售单号"/>
  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. <a-input id="urgentItemsOffsetList-urgentBillNo" v-model.trim="queryParam.urgentBillNo" allowClear placeholder="请输入急件单号"/>
  27. </a-form-item>
  28. </a-col>
  29. <!-- <a-col :md="6" :sm="24">
  30. <a-form-item label="单据来源">
  31. <v-select
  32. v-model="queryParam.sourceType"
  33. ref="sourceType"
  34. id="urgentItemsOffsetList-sourceType"
  35. code="SALES_SOURCE"
  36. placeholder="请选择单据来源"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col> -->
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="状态">
  42. <v-select
  43. v-model="queryParam.status"
  44. ref="status"
  45. id="urgentItemsOffsetList-status"
  46. code="URGENT_STATUS"
  47. placeholder="请选择状态"
  48. allowClear></v-select>
  49. </a-form-item>
  50. </a-col>
  51. </template>
  52. <a-col :md="6" :sm="24">
  53. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="urgentItemsOffsetList-refresh">查询</a-button>
  54. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="urgentItemsOffsetList-reset">重置</a-button>
  55. <a @click="advanced=!advanced" style="margin-left: 8px" id="urgentItemsOffsetList-advanced">
  56. {{ advanced ? '收起' : '展开' }}
  57. <a-icon :type="advanced ? 'up' : 'down'"/>
  58. </a>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. </div>
  63. <!-- 列表 -->
  64. <s-table
  65. class="sTable fixPagination"
  66. ref="table"
  67. :style="{ height: tableHeight+84.5+'px' }"
  68. size="small"
  69. :rowKey="(record) => record.id"
  70. :columns="columns"
  71. :data="loadData"
  72. :scroll="{ y: tableHeight }"
  73. :defaultLoadData="false"
  74. bordered>
  75. <!-- 单号 -->
  76. <template slot="urgentBillNo" slot-scope="text, record">
  77. <span class="table-td-link" :id="'urgentItemsOffsetDetail-view-'+record.id" v-if="$hasPermissions('M_urgentDetail')" @click="handleDetail(record)">{{ record.urgentBillNo }}</span>
  78. <span v-else>{{ record.urgentBillNo }}</span>
  79. </template>
  80. <!-- 状态 -->
  81. <template slot="status" slot-scope="text, record">
  82. <stateIcon :title="record.statusDictValue" :state="record.status=='WAIT'?'2':'1'"></stateIcon>
  83. </template>
  84. <!-- 操作 -->
  85. <template slot="action" slot-scope="text, record">
  86. <a-button
  87. size="small"
  88. type="link"
  89. v-if="record.status == 'WAIT' && $hasPermissions('B_urgentWriteDown')"
  90. @click="handleWriteDown(record)"
  91. class="button-primary"
  92. :id="'urgentItemsOffsetDetail-writeDown-'+record.id">冲减</a-button>
  93. <span v-else>--</span>
  94. </template>
  95. </s-table>
  96. </a-spin>
  97. </a-card>
  98. </template>
  99. <script>
  100. import { commonMixin } from '@/utils/mixin'
  101. import getDate from '@/libs/getDate.js'
  102. import { urgentList, urgentWriteDown } from '@/api/urgent'
  103. // 组件
  104. import { STable, VSelect } from '@/components'
  105. import rangeDate from '@/views/common/rangeDate.vue'
  106. import stateIcon from '@/views/common/stateIcon'
  107. import custList from '@/views/common/custList.vue'
  108. export default {
  109. name: 'UrgentOffsetList',
  110. components: { STable, VSelect, rangeDate, custList, stateIcon },
  111. mixins: [commonMixin],
  112. data () {
  113. const _this = this
  114. return {
  115. spinning: false,
  116. tableHeight: 0, // 表格高度
  117. advanced: true, // 高级搜索 展开/关闭
  118. time: [ // 创建时间默认值
  119. getDate.getCurrMonthDays().starttime,
  120. getDate.getCurrMonthDays().endtime
  121. ],
  122. queryParam: { // 查询条件
  123. beginDate: getDate.getCurrMonthDays().starttime, // 开始时间
  124. endDate: getDate.getCurrMonthDays().endtime, // 结束时间
  125. buyerNameCurrent: undefined, // 客户名称
  126. bizBillNo: '', // 关联单号
  127. urgentBillNo: '', // 急件单号
  128. status: undefined, // 状态
  129. sourceType: undefined // 单据来源
  130. },
  131. disabled: false, // 查询、重置按钮是否可操作
  132. columns: [
  133. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  134. { title: '急件单号', scopedSlots: { customRender: 'urgentBillNo' }, width: '15%', align: 'center' },
  135. { title: '关联单号', dataIndex: 'bizBillNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  136. // { title: '销售单来源', dataIndex: 'sourceTypeDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '客户名称', dataIndex: 'buyerNameCurrent', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '总款数', dataIndex: 'totalCategory', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  139. { title: '总数量', dataIndex: 'totalQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  140. { title: '总成本', dataIndex: 'totalCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  141. { title: '总售价', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  142. { title: '毛利', dataIndex: 'grossProfit', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  143. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '冲减时间', dataIndex: 'offSetTime', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '状态', scopedSlots: { customRender: 'status' }, width: '4%', align: 'center' },
  146. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  147. ],
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: parameter => {
  150. this.disabled = true
  151. this.spinning = true
  152. return urgentList(Object.assign(parameter, this.queryParam)).then(res => {
  153. let data
  154. if (res.status == 200) {
  155. data = res.data
  156. const no = (data.pageNo - 1) * data.pageSize
  157. for (var i = 0; i < data.list.length; i++) {
  158. data.list[i].no = no + i + 1
  159. }
  160. this.disabled = false
  161. }
  162. this.spinning = false
  163. return data
  164. })
  165. }
  166. }
  167. },
  168. methods: {
  169. // 创建时间选择
  170. dateChange (date) {
  171. this.queryParam.beginDate = date[0]
  172. this.queryParam.endDate = date[1]
  173. },
  174. // 冲减
  175. handleWriteDown (row) {
  176. const _this = this
  177. this.$confirm({
  178. title: '提示',
  179. content: '确定要进行冲减吗?',
  180. centered: true,
  181. onOk () {
  182. _this.disabled = true
  183. _this.spinning = true
  184. urgentWriteDown({ urgentBillSn: row.urgentBillSn }).then(res => {
  185. if (res.status == 200) {
  186. _this.$message.success(res.message)
  187. _this.$refs.table.refresh()
  188. }
  189. _this.disabled = false
  190. _this.spinning = false
  191. })
  192. }
  193. })
  194. },
  195. // 重置列表
  196. resetSearchForm () {
  197. this.$refs.rangeDate.resetDate(this.time)
  198. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  199. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  200. this.queryParam.buyerNameCurrent = undefined
  201. this.queryParam.bizBillNo = ''
  202. this.queryParam.urgentBillNo = ''
  203. this.queryParam.status = undefined
  204. this.queryParam.sourceType = undefined
  205. this.$refs.custList.resetForm()
  206. this.$refs.table.refresh(true)
  207. },
  208. // 查看详情
  209. handleDetail (row) {
  210. this.$router.push({ name: 'urgentItemsOffsetDetail', params: { sn: row.urgentBillSn } })
  211. },
  212. // 页面初始化
  213. pageInit () {
  214. const _this = this
  215. this.$nextTick(() => { // 页面渲染完成后的回调
  216. _this.setTableH()
  217. })
  218. },
  219. // 计算表格高度
  220. setTableH () {
  221. const tableSearchH = this.$refs.tableSearch.offsetHeight
  222. this.tableHeight = window.innerHeight - tableSearchH - 195
  223. }
  224. },
  225. mounted () {
  226. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  227. this.pageInit()
  228. this.resetSearchForm()
  229. }
  230. },
  231. watch: {
  232. // 展开收起
  233. advanced (newValue, oldValue) {
  234. const _this = this
  235. this.$nextTick(() => { // 页面渲染完成后的回调
  236. _this.setTableH()
  237. })
  238. },
  239. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  240. this.setTableH()
  241. }
  242. },
  243. activated () {
  244. // 如果是新页签打开,则重置当前页面
  245. if (this.$store.state.app.isNewTab) {
  246. this.pageInit()
  247. this.resetSearchForm()
  248. }
  249. // 只刷新列表
  250. if (this.$store.state.app.updateList) {
  251. this.pageInit()
  252. this.$refs.table.refresh()
  253. }
  254. },
  255. beforeRouteEnter (to, from, next) {
  256. next(vm => {})
  257. }
  258. }
  259. </script>
  260. <style lang="less">
  261. .urgentItemsOffsetList-wrap{
  262. .red{
  263. color: #ed1c24;
  264. }
  265. .green{
  266. color: #19be6b;
  267. }
  268. }
  269. </style>