purchaseAmountModal.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <a-modal
  3. title="采购数量"
  4. v-model="purchaseAmountModVis"
  5. :confirmLoading="confirmLoading"
  6. width="86%"
  7. :footer="null"
  8. @cancel="close"
  9. >
  10. <!-- tabel 加载 -->
  11. <a-spin :spinning="confirmLoading">
  12. <!-- 查询 -->
  13. <div class="table-page-search-wrapper">
  14. <a-form layout="inline" @keyup.enter.native="searchQuery">
  15. <a-row :gutter="24">
  16. <a-col :md="6" :sm="8">
  17. <a-form-item label="单据号">
  18. <a-input placeholder="请输入单据号" v-model="queryParam.ccode"></a-input>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="8">
  22. <a-form-item label="批号">
  23. <a-input placeholder="请输入批号" v-model="queryParam.cbatch"></a-input>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="8">
  27. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  28. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  29. <a-button type="primary" icon="download" @click="exportExcel" style="margin-left: 8px">导出</a-button>
  30. <JsonExcel
  31. :fetch="getExportDataList"
  32. :fields="exportFields"
  33. :header="exportTitle"
  34. name="采购数量.xls"
  35. style="display:none"
  36. >
  37. <!-- 上面可以自定义自己的样式,还可以引用其他组件button -->
  38. <a-button type="primary" icon="download" ref="realExportExcel">导出</a-button>
  39. </JsonExcel>
  40. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  41. </span>
  42. </a-col>
  43. </a-row>
  44. </a-form>
  45. </div>
  46. <!-- table -->
  47. <div>
  48. <a-table
  49. ref="tableRef"
  50. :loading="loading"
  51. bordered
  52. :columns="purchaseAmountColumns"
  53. :data-source="purchaseAmountData"
  54. :pagination="false"
  55. :scroll="{ y: 500,x:1500 }"
  56. :footer="showTotal"
  57. >
  58. </a-table>
  59. <!-- 导出 打印 返回 -->
  60. <a-row style="marginTop:20px;">
  61. <a-col :md="24" :sm="12">
  62. <span style="float: right;" class="table-operator">
  63. <a-button type="primary" @click="backFabricLossTable" icon="rollback">关闭</a-button>
  64. </span>
  65. </a-col>
  66. </a-row>
  67. </div>
  68. </a-spin>
  69. </a-modal>
  70. </template>
  71. <script>
  72. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  73. import JEllipsis from '@/components/jeecg/JEllipsis'
  74. import JsonExcel from 'vue-json-excel'
  75. export default {
  76. name: 'PurchaseAmountModal', // 采购数量 弹框
  77. mixins: [JeecgListMixin],
  78. components: { JEllipsis ,JsonExcel},
  79. data() {
  80. return {
  81. exportTitle:"采购数量",
  82. // 表头
  83. purchaseAmountColumns: [
  84. {
  85. title: '序号',
  86. width:80,
  87. customRender: (text, record, index) => {
  88. if (record.ccode == "合计")
  89. return "";
  90. else
  91. return index + 1;
  92. }
  93. },
  94. {
  95. title: '单据号',
  96. dataIndex: 'ccode',
  97. width: 120,
  98. key: '',
  99. className: 'replacecolor'
  100. },
  101. {
  102. title: '存货编码',
  103. dataIndex: 'cinvCode',
  104. width: 120,
  105. key: '',
  106. className: 'replacecolor'
  107. },
  108. {
  109. title: '存货名称',
  110. dataIndex: 'ccode',
  111. width: 240,
  112. key: '',
  113. className: 'replacecolor',
  114. customRender: (text, record, index) => {
  115. if (record.ccode == "合计")
  116. return "";
  117. else
  118. return record.cinvName + ' ' + record.ccolor;
  119. }
  120. },
  121. {
  122. title: '批号',
  123. dataIndex: 'cbatch',
  124. width: 120,
  125. key: '',
  126. className: 'replacecolor'
  127. },
  128. {
  129. title: '入库单数量',
  130. dataIndex: 'iquantity',
  131. width: 120,
  132. key: '',
  133. className: 'replacecolor'
  134. },
  135. {
  136. title: '含税单价',
  137. dataIndex: 'iprice',
  138. width: 120,
  139. key: '',
  140. className: 'replacecolor'
  141. },
  142. {
  143. title: '开票数',
  144. dataIndex: 'iquantityInvoice',
  145. width: 100,
  146. key: '',
  147. className: 'replacecolor'
  148. },
  149. {
  150. title: '未开票数',
  151. dataIndex: 'iquantityNInvoice',
  152. width: 100,
  153. key: '',
  154. className: 'replacecolor'
  155. },
  156. {
  157. title: '结算数量',
  158. dataIndex: 'iquantitySettle',
  159. width: 100,
  160. key: '',
  161. className: 'replacecolor'
  162. },
  163. {
  164. title: '未结算数量',
  165. dataIndex: 'iquantityNSettle',
  166. width: 100,
  167. key: '',
  168. className: 'replacecolor'
  169. }
  170. ],
  171. purchaseAmountData: [],
  172. allDataList:[],
  173. loading: false, // 表格加载
  174. // orderDataform: this.$form.createForm(this),
  175. confirmLoading: false,
  176. purchaseAmountModVis: false,
  177. // 查询条件
  178. queryParam: {
  179. ccode: '', // 纱批
  180. cbatch: '' // 采购单价
  181. }
  182. }
  183. },
  184. // 接收父组件 方法
  185. props: {
  186. father: {
  187. type: Function,
  188. default: null
  189. }
  190. },
  191. computed: {
  192. // 合计展示
  193. totalDataSource(){
  194. // 开票成本-衬衣 合计
  195. var item = {
  196. "ccode":"合计"
  197. };
  198. var iquantity = 0,iquantityInvoice=0,iquantityNInvoice=0,iquantitySettle=0,iquantityNSettle=0;
  199. for (let row of this.purchaseAmountData){
  200. iquantity += row.iquantity*1;
  201. iquantityInvoice += row.iquantityInvoice*1;
  202. iquantityNInvoice += row.iquantityNInvoice*1;
  203. iquantitySettle += row.iquantitySettle*1;
  204. iquantityNSettle += row.iquantityNSettle*1;
  205. }
  206. item.iquantity= parseFloat(iquantity.toFixed(4));
  207. item.iquantityInvoice = parseFloat(iquantityInvoice.toFixed(4));
  208. item.iquantityNInvoice = parseFloat(iquantityNInvoice.toFixed(4));
  209. item.iquantitySettle = parseFloat(iquantitySettle.toFixed(4));
  210. item.iquantityNSettle = parseFloat(iquantityNSettle.toFixed(4));
  211. return [item];
  212. },
  213. // 获取导出json定义
  214. exportFields(){
  215. var ret = {};
  216. this.purchaseAmountColumns.forEach((record,index)=>{
  217. if (record.title != "序号"){
  218. if (record.title != "单据号")
  219. ret[record.title] = record.dataIndex;
  220. else
  221. ret[record.title] = record.dataIndex+"_ex";
  222. }
  223. });
  224. return ret;
  225. }
  226. },
  227. created() {},
  228. watch:{
  229. purchaseAmountData(){
  230. this.$nextTick(()=>{
  231. const dom = this.$refs.tableRef.$el.getElementsByClassName('ant-table-body')[0];
  232. dom.addEventListener(
  233. 'scroll',
  234. () => {
  235. this.$refs.tableInfo.$el.querySelectorAll(
  236. '.ant-table-body'
  237. )[0].scrollLeft = dom.scrollLeft
  238. },
  239. true
  240. )
  241. })
  242. }
  243. },
  244. methods: {
  245. // 第一行 导出
  246. // handleExportXls() {},
  247. // 打印
  248. print() {},
  249. // 返回
  250. backFabricLossTable() {
  251. console.log('返回到面料损耗表')
  252. // this.$router.push('fabricLoss-table')
  253. // this.purchaseAmountModVis = false
  254. this.close()
  255. },
  256. // 弹框查询按钮
  257. searchQuery() {
  258. var data = []
  259. this.allDataList.map(item=>{
  260. if(!item.ccode){item.ccode = ''}
  261. if(!item.cbatch){item.cbatch = ''}
  262. if(item.ccode.includes(this.queryParam.ccode) && item.cbatch.includes(this.queryParam.cbatch)){
  263. data.push(item)
  264. }
  265. });
  266. this.purchaseAmountData =data
  267. },
  268. // 重置
  269. searchReset() {
  270. this.queryParam ={
  271. ccode:'',
  272. cbatch:''
  273. }
  274. this.purchaseAmountData = this.allDataList
  275. // this.getShipmentList()
  276. },
  277. close() {
  278. this.$emit('close')
  279. this.purchaseAmountModVis = false
  280. this.searchReset()
  281. },
  282. showTotal(data) {
  283. return (
  284. <a-table
  285. ref="tableInfo"
  286. rowKey={Math.random}
  287. bordered={false}
  288. pagination={false}
  289. columns={this.purchaseAmountColumns}
  290. dataSource={this.totalDataSource || []}
  291. showHeader={false}
  292. scroll={{x:1500 }}
  293. ></a-table>
  294. )
  295. },
  296. // 导出excel
  297. exportExcel(){
  298. this.$refs.realExportExcel.$el.click();
  299. },
  300. // 生成导出数据
  301. getExportDataList(){
  302. this.purchaseAmountData.forEach((item,index)=>{item["ccode_ex"]="&nbsp;"+item["ccode"]});
  303. return this.purchaseAmountData;
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="less" scoped>
  309. @import '~@assets/less/common.less';
  310. @import '~@assets/less/overwriter.less';
  311. /deep/ .ant-table-thead > tr > th {
  312. text-align: center;
  313. // font-weight: 700;
  314. }
  315. /deep/ .ant-table-tbody {
  316. text-align: center;
  317. }
  318. /deep/ .ant-table-footer .ant-table-body {
  319. overflow: hidden !important;
  320. }
  321. /deep/.ant-modal-body{
  322. height: auto !important;
  323. overflow-y: scroll;
  324. }
  325. // /deep/ th.replacecolor {
  326. // background-color: #ccc;
  327. // }
  328. </style>