LinkBillList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <template>
  2. <div ref="container">
  3. <a-modal
  4. :title="title"
  5. :width="1250"
  6. :visible="visible"
  7. :getContainer="() => $refs.container"
  8. :maskStyle="{ top: '93px', left: '154px' }"
  9. :wrapClassName="wrapClassNameInfo()"
  10. :mask="isDesktop()"
  11. :maskClosable="false"
  12. @ok="handleOk"
  13. @cancel="handleCancel"
  14. cancelText="关闭"
  15. style="top: 20px; height: 95%"
  16. >
  17. <!-- 查询区域 -->
  18. <div class="table-page-search-wrapper" v-if="selectType === 'list'">
  19. <!-- 搜索区域 -->
  20. <a-form layout="inline" @keyup.enter.native="searchQuery">
  21. <a-row :gutter="24">
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="单据编号" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18, offset: 1 }">
  24. <a-input placeholder="请输入单据编号查询" v-model="queryParam.number"></a-input>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="商品信息" :labelCol="{ span: 5 }" :wrapperCol="{ span: 18, offset: 1 }">
  29. <a-input placeholder="条码|名称|规格|型号" v-model="queryParam.materialParam"></a-input>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="单据日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  34. <a-range-picker
  35. style="width: 100%"
  36. v-model="queryParam.createTimeRange"
  37. format="YYYY-MM-DD"
  38. :placeholder="['开始时间', '结束时间']"
  39. @change="onDateChange"
  40. @ok="onDateOk"
  41. />
  42. </a-form-item>
  43. </a-col>
  44. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  45. <a-col :md="6" :sm="24">
  46. <a-button type="primary" @click="searchQuery">查询</a-button>
  47. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  48. </a-col>
  49. </span>
  50. </a-row>
  51. </a-form>
  52. </div>
  53. <!-- table区域-begin -->
  54. <a-table
  55. v-if="selectType === 'list'"
  56. bordered
  57. ref="table"
  58. size="middle"
  59. rowKey="id"
  60. :columns="columns"
  61. :dataSource="dataSource"
  62. :pagination="ipagination"
  63. :loading="loading"
  64. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: getType }"
  65. :customRow="rowAction"
  66. @change="handleTableChange"
  67. >
  68. <span slot="numberCustomRender" slot-scope="text, record">
  69. <a v-if="!queryParam.purchaseStatus" @click="myHandleDetail(record)">{{ record.number }}</a>
  70. <span v-if="queryParam.purchaseStatus">{{ record.number }}</span>
  71. </span>
  72. <template slot="customRenderStatus" slot-scope="text, record">
  73. <template v-if="!queryParam.purchaseStatus">
  74. <a-tag v-if="record.status === '0'" color="red">未审核</a-tag>
  75. <a-tag v-if="record.status === '1'" color="green">已审核</a-tag>
  76. <a-tag v-if="record.status === '2' && queryParam.subType === '请购单'" color="cyan">完成采购</a-tag>
  77. <a-tag v-if="record.status === '2' && queryParam.subType === '采购订单'" color="cyan">完成采购</a-tag>
  78. <a-tag v-if="record.status === '2' && queryParam.subType === '销售订单'" color="cyan">完成销售</a-tag>
  79. <a-tag v-if="record.status === '3' && queryParam.subType === '请购单'" color="blue">部分采购</a-tag>
  80. <a-tag v-if="record.status === '3' && queryParam.subType === '采购订单'" color="blue">部分采购</a-tag>
  81. <a-tag v-if="record.status === '3' && queryParam.subType === '销售订单'" color="blue">部分销售</a-tag>
  82. <a-tag
  83. v-if="record.status === '2' && (queryParam.subType === '采购' || queryParam.subType === '销售')"
  84. color="green"
  85. >已审核</a-tag
  86. >
  87. <a-tag
  88. v-if="record.status === '3' && (queryParam.subType === '采购' || queryParam.subType === '销售')"
  89. color="green"
  90. >已审核</a-tag
  91. >
  92. </template>
  93. <template v-if="queryParam.purchaseStatus">
  94. <a-tag v-if="record.purchaseStatus === '0'" color="red">未采购</a-tag>
  95. <a-tag v-if="record.purchaseStatus === '2' && queryParam.subType === '销售订单'" color="cyan"
  96. >完成采购</a-tag
  97. >
  98. <a-tag v-if="record.purchaseStatus === '3' && queryParam.subType === '销售订单'" color="blue"
  99. >部分采购</a-tag
  100. >
  101. </template>
  102. </template>
  103. </a-table>
  104. <a-table
  105. v-if="selectType === 'detail'"
  106. bordered
  107. ref="table"
  108. size="middle"
  109. rowKey="id"
  110. :pagination="false"
  111. :columns="columnsDetail"
  112. :dataSource="dataSourceDetail"
  113. :loading="loading"
  114. :rowSelection="{ selectedRowKeys: selectedDetailRowKeys, onChange: onSelectDetailChange, type: 'checkbox' }"
  115. @change="handleTableChange"
  116. >
  117. </a-table>
  118. <!-- table区域-end -->
  119. <!-- 表单区域 -->
  120. <bill-detail ref="billDetail"></bill-detail>
  121. </a-modal>
  122. </div>
  123. </template>
  124. <script>
  125. import BillDetail from './BillDetail'
  126. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  127. import { mixinDevice } from '@/utils/mixin'
  128. import { findBillDetailByNumber } from '@/api/api'
  129. import { getAction } from '@/api/manage'
  130. import Vue from 'vue'
  131. export default {
  132. name: 'LinkBillList',
  133. mixins: [JeecgListMixin, mixinDevice],
  134. components: {
  135. BillDetail,
  136. },
  137. data() {
  138. return {
  139. title: '操作',
  140. visible: false,
  141. disableMixinCreated: true,
  142. selectedRowKeys: [],
  143. selectedDetailRowKeys: [],
  144. selectBillRows: [],
  145. selectBillDetailRows: [],
  146. showType: 'basic',
  147. selectType: 'list',
  148. linkNumber: '',
  149. organId: '',
  150. accountId: '',
  151. salesMan: '',
  152. discountMoney: '',
  153. deposit: '',
  154. remark: '',
  155. depotId: '',
  156. queryParam: {
  157. number: '',
  158. materialParam: '',
  159. type: '',
  160. subType: '',
  161. status: '',
  162. },
  163. labelCol: {
  164. xs: { span: 24 },
  165. sm: { span: 8 },
  166. },
  167. wrapperCol: {
  168. xs: { span: 24 },
  169. sm: { span: 16 },
  170. },
  171. // 表头
  172. columns: [
  173. { title: '', dataIndex: 'organName', width: 120, ellipsis: true },
  174. { title: '单据编号', dataIndex: 'number', width: 130, scopedSlots: { customRender: 'numberCustomRender' } },
  175. {
  176. title: '商品信息',
  177. dataIndex: 'materialsList',
  178. width: 280,
  179. ellipsis: true,
  180. customRender: function (text, record, index) {
  181. if (text) {
  182. return text.replace(',', ',')
  183. }
  184. },
  185. },
  186. { title: '单据日期', dataIndex: 'operTimeStr', width: 145 },
  187. { title: '操作员', dataIndex: 'userName', width: 70 },
  188. { title: '数量', dataIndex: 'materialCount', width: 60 },
  189. { title: '金额合计', dataIndex: 'totalPrice', width: 70 },
  190. {
  191. title: '含税合计',
  192. dataIndex: 'totalTaxLastMoney',
  193. width: 70,
  194. customRender: function (text, record, index) {
  195. if (record.discountLastMoney) {
  196. return (record.discountMoney + record.discountLastMoney).toFixed(2)
  197. } else {
  198. return record.totalPrice
  199. }
  200. },
  201. },
  202. {
  203. title: '状态',
  204. dataIndex: 'status',
  205. width: 70,
  206. align: 'center',
  207. scopedSlots: { customRender: 'customRenderStatus' },
  208. },
  209. ],
  210. columnsDetail: [
  211. { title: '条码', dataIndex: 'barCode', width: 120 },
  212. { title: '名称', dataIndex: 'name', width: 100, ellipsis: true },
  213. { title: '规格', dataIndex: 'standard', width: 100, ellipsis: true },
  214. { title: '型号', dataIndex: 'model', width: 150, ellipsis: true },
  215. { title: '单位', dataIndex: 'unit', width: 50 },
  216. { title: '数量', dataIndex: 'operNumber', width: 80 },
  217. { title: '单价', dataIndex: 'unitPrice', width: 80 },
  218. { title: '金额', dataIndex: 'allPrice', width: 80 },
  219. { title: '税率(%)', dataIndex: 'taxRate', width: 80 },
  220. { title: '税额', dataIndex: 'taxMoney', width: 80 },
  221. { title: '价税合计', dataIndex: 'taxLastMoney', width: 80 },
  222. { title: '备注', dataIndex: 'remark', width: 100, ellipsis: true },
  223. ],
  224. dataSource: [],
  225. dataSourceDetail: [],
  226. url: {
  227. list: '/depotHead/list',
  228. },
  229. }
  230. },
  231. computed: {
  232. getType: function () {
  233. return 'radio'
  234. },
  235. },
  236. created() {},
  237. methods: {
  238. show(type, subType, organType, status) {
  239. this.selectType = 'list'
  240. this.showType = 'basic'
  241. this.queryParam.type = type
  242. this.queryParam.subType = subType
  243. this.queryParam.status = status
  244. this.model = Object.assign({}, {})
  245. this.visible = true
  246. this.initColumns(subType, organType)
  247. this.loadData(1)
  248. },
  249. purchaseShow(type, subType, organType, status, purchaseStatus) {
  250. this.selectType = 'list'
  251. this.showType = 'purchase'
  252. this.queryParam.type = type
  253. this.queryParam.subType = subType
  254. this.queryParam.status = status
  255. this.queryParam.purchaseStatus = purchaseStatus
  256. this.model = Object.assign({}, {})
  257. this.visible = true
  258. this.initColumns(subType, organType)
  259. this.loadData(1)
  260. },
  261. initColumns(subType, organType) {
  262. for (let i = 0; i < this.columns.length; i++) {
  263. if (this.columns[i].dataIndex === 'organName') {
  264. this.columns[i].title = organType
  265. }
  266. }
  267. if (subType === '请购单') {
  268. for (let i = 0; i < this.columns.length; i++) {
  269. if (this.columns[i].dataIndex === 'organName') {
  270. this.columns.splice(i, 1)
  271. }
  272. if (this.columns[i].dataIndex === 'totalPrice') {
  273. this.columns.splice(i, 1)
  274. }
  275. if (this.columns[i].dataIndex === 'totalTaxLastMoney') {
  276. this.columns.splice(i, 1)
  277. }
  278. }
  279. }
  280. },
  281. myHandleDetail(record) {
  282. findBillDetailByNumber({ number: record.number }).then((res) => {
  283. if (res && res.code === 200) {
  284. let type = res.data.depotHeadType
  285. type = type.replace('其它', '')
  286. this.$refs.billDetail.show(res.data, type)
  287. this.$refs.billDetail.title = type + '-详情'
  288. }
  289. })
  290. },
  291. close() {
  292. this.$emit('close')
  293. this.visible = false
  294. },
  295. handleCancel() {
  296. this.close()
  297. },
  298. onSelectChange(selectedRowKeys) {
  299. this.selectedRowKeys = selectedRowKeys
  300. },
  301. onSelectDetailChange(selectedRowKeys) {
  302. this.selectedDetailRowKeys = selectedRowKeys
  303. },
  304. handleOk() {
  305. if (this.selectType === 'list') {
  306. this.getSelectBillRows()
  307. this.selectType = 'detail'
  308. this.title = '请选择单据明细'
  309. if (this.selectBillRows && this.selectBillRows.length > 0) {
  310. let record = this.selectBillRows[0]
  311. console.log('this.selectBillRows======', this.selectBillRows)
  312. this.linkNumber = record.number
  313. this.organId = record.organId
  314. this.accountId = record.accountId
  315. this.salesMan = record.salesMan
  316. this.discountMoney = record.discountMoney
  317. this.deposit = record.changeAmount - record.finishDeposit
  318. this.remark = record.remark
  319. this.depotId = record.depotId
  320. this.initListColumns()
  321. this.loadDetailData(1)
  322. }
  323. } else {
  324. if (this.selectedDetailRowKeys.length) {
  325. this.getSelectBillDetailRows()
  326. this.$emit(
  327. 'ok',
  328. this.selectBillDetailRows,
  329. this.linkNumber,
  330. this.organId,
  331. this.discountMoney,
  332. this.deposit,
  333. this.remark,
  334. this.depotId,
  335. this.accountId,
  336. this.salesMan
  337. )
  338. this.close()
  339. } else {
  340. this.$message.warning('抱歉,请选择单据明细!')
  341. }
  342. }
  343. },
  344. initListColumns() {
  345. if (this.queryParam.subType === '请购单') {
  346. for (let i = 0; i < this.columnsDetail.length; i++) {
  347. if (this.columnsDetail[i].dataIndex === 'unitPrice') {
  348. this.columnsDetail.splice(i, 1)
  349. }
  350. if (this.columnsDetail[i].dataIndex === 'allPrice') {
  351. this.columnsDetail.splice(i, 1)
  352. }
  353. if (this.columnsDetail[i].dataIndex === 'taxRate') {
  354. this.columnsDetail.splice(i, 1)
  355. }
  356. if (this.columnsDetail[i].dataIndex === 'taxMoney') {
  357. this.columnsDetail.splice(i, 1)
  358. }
  359. if (this.columnsDetail[i].dataIndex === 'taxLastMoney') {
  360. this.columnsDetail.splice(i, 1)
  361. }
  362. }
  363. }
  364. },
  365. //查询明细列表
  366. loadDetailData(arg) {
  367. //加载数据 若传入参数1则加载第一页的内容
  368. if (arg === 1) {
  369. this.ipagination.current = 1
  370. }
  371. if (this.selectBillRows && this.selectBillRows.length > 0) {
  372. let record = this.selectBillRows[0]
  373. let param = {
  374. headerId: record.id,
  375. mpList: '',
  376. linkType: this.showType,
  377. }
  378. this.loading = true
  379. getAction('/depotItem/getDetailList', param).then((res) => {
  380. if (res.code === 200) {
  381. let list = res.data.rows
  382. let listEx = []
  383. for (let j = 0; j < list.length; j++) {
  384. let info = list[j]
  385. if (info.finishNumber < info.preNumber) {
  386. //去掉已经全部转换的明细,只加载未转换完的明细
  387. listEx.push(info)
  388. } else {
  389. if (
  390. this.queryParam.subType === '采购' ||
  391. this.queryParam.subType === '销售' ||
  392. this.queryParam.subType === '零售'
  393. ) {
  394. //针对退货单,不过滤明细
  395. listEx.push(info)
  396. }
  397. }
  398. }
  399. this.dataSourceDetail = listEx
  400. this.ipagination.total = res.data.total
  401. }
  402. if (res.code === 510) {
  403. this.$message.warning(res.data)
  404. }
  405. this.loading = false
  406. })
  407. }
  408. },
  409. onDateChange: function (value, dateString) {
  410. this.queryParam.beginTime = dateString[0]
  411. this.queryParam.endTime = dateString[1]
  412. },
  413. onDateOk(value) {
  414. console.log(value)
  415. },
  416. searchReset() {
  417. this.queryParam = {
  418. type: this.queryParam.type,
  419. subType: this.queryParam.subType,
  420. status: '1,3',
  421. }
  422. this.loadData(1)
  423. },
  424. getSelectBillRows() {
  425. let dataSource = this.dataSource
  426. this.selectBillRows = []
  427. for (let i = 0, len = dataSource.length; i < len; i++) {
  428. if (this.selectedRowKeys.includes(dataSource[i].id)) {
  429. this.selectBillRows.push(dataSource[i])
  430. }
  431. }
  432. },
  433. getSelectBillDetailRows() {
  434. let dataSource = this.dataSourceDetail
  435. this.selectBillDetailRows = []
  436. for (let i = 0, len = dataSource.length; i < len; i++) {
  437. if (this.selectedDetailRowKeys.includes(dataSource[i].id)) {
  438. this.selectBillDetailRows.push(dataSource[i])
  439. }
  440. }
  441. },
  442. rowAction(record, index) {
  443. return {
  444. on: {
  445. click: () => {
  446. let arr = []
  447. arr.push(record.id)
  448. this.selectedRowKeys = arr
  449. },
  450. dblclick: () => {
  451. let arr = []
  452. arr.push(record.id)
  453. this.selectedRowKeys = arr
  454. this.handleOk()
  455. },
  456. },
  457. }
  458. },
  459. },
  460. }
  461. </script>
  462. <style scoped></style>