purchaseAmountModal.vue 8.4 KB

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