purchaseAmountModal.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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: 'cinvCode',
  98. width: 120,
  99. key: '',
  100. className: 'replacecolor'
  101. },
  102. {
  103. title: '存货名称',
  104. dataIndex: 'ccode',
  105. width: 240,
  106. key: '',
  107. className: 'replacecolor',
  108. customRender: (text, record, index) => {
  109. return record.cinvName + ' ' + record.ccolor;
  110. }
  111. },
  112. {
  113. title: '批号',
  114. dataIndex: 'cbatch',
  115. width: 120,
  116. key: '',
  117. className: 'replacecolor'
  118. },
  119. {
  120. title: '入库单数量',
  121. dataIndex: 'iquantity',
  122. width: 120,
  123. key: '',
  124. className: 'replacecolor'
  125. },
  126. {
  127. title: '含税单价',
  128. dataIndex: 'iprice',
  129. width: 120,
  130. key: '',
  131. className: 'replacecolor'
  132. },
  133. {
  134. title: '开票数',
  135. dataIndex: 'iquantityInvoice',
  136. width: 100,
  137. key: '',
  138. className: 'replacecolor'
  139. },
  140. {
  141. title: '未开票数',
  142. dataIndex: 'iquantityNInvoice',
  143. width: 100,
  144. key: '',
  145. className: 'replacecolor'
  146. },
  147. {
  148. title: '结算数量',
  149. dataIndex: 'iquantitySettle',
  150. width: 100,
  151. key: '',
  152. className: 'replacecolor'
  153. },
  154. {
  155. title: '未结算数量',
  156. dataIndex: 'iquantityNSettle',
  157. width: 100,
  158. key: '',
  159. className: 'replacecolor'
  160. }
  161. ],
  162. purchaseAmountData: [],
  163. allDataList:[],
  164. loading: false, // 表格加载
  165. // orderDataform: this.$form.createForm(this),
  166. confirmLoading: false,
  167. purchaseAmountModVis: false,
  168. // 查询条件
  169. queryParam: {
  170. yarnNum: '', // 纱批
  171. purchasePrice: '' // 采购单价
  172. }
  173. }
  174. },
  175. // 接收父组件 方法
  176. props: {
  177. father: {
  178. type: Function,
  179. default: null
  180. }
  181. },
  182. computed: {
  183. // 合计展示
  184. totalDataSource(){
  185. // 开票成本-衬衣 合计
  186. var item = {
  187. "ccode":"合计"
  188. };
  189. var iquantity = 0,iquantityInvoice=0,iquantityNInvoice=0,iquantitySettle=0,iquantityNSettle=0;
  190. for (let row of this.purchaseAmountData){
  191. iquantity += row.iquantity*1;
  192. iquantityInvoice += row.iquantityInvoice*1;
  193. iquantityNInvoice += row.iquantityNInvoice*1;
  194. iquantitySettle += row.iquantitySettle*1;
  195. iquantityNSettle += row.iquantityNSettle*1;
  196. }
  197. item.iquantity= parseFloat(iquantity.toFixed(4));
  198. item.iquantityInvoice = parseFloat(iquantityInvoice.toFixed(4));
  199. item.iquantityNInvoice = parseFloat(iquantityNInvoice.toFixed(4));
  200. item.iquantitySettle = parseFloat(iquantitySettle.toFixed(4));
  201. item.iquantityNSettle = parseFloat(iquantityNSettle.toFixed(4));
  202. return [item];
  203. },
  204. // 获取导出json定义
  205. exportFields(){
  206. var ret = {};
  207. this.purchaseAmountColumns.forEach((record,index)=>{
  208. if (record.title != "序号"){
  209. if (record.title != "单据号")
  210. ret[record.title] = record.dataIndex;
  211. else
  212. ret[record.title] = record.dataIndex+"_ex";
  213. }
  214. });
  215. return ret;
  216. }
  217. },
  218. created() {},
  219. watch:{
  220. purchaseAmountData(){
  221. this.$nextTick(()=>{
  222. const dom = this.$refs.tableRef.$el.getElementsByClassName('ant-table-body')[0];
  223. dom.addEventListener(
  224. 'scroll',
  225. () => {
  226. this.$refs.tableInfo.$el.querySelectorAll(
  227. '.ant-table-body'
  228. )[0].scrollLeft = dom.scrollLeft
  229. },
  230. true
  231. )
  232. })
  233. }
  234. },
  235. methods: {
  236. // 第一行 导出
  237. // handleExportXls() {},
  238. // 打印
  239. print() {},
  240. // 返回
  241. backFabricLossTable() {
  242. console.log('返回到面料损耗表')
  243. // this.$router.push('fabricLoss-table')
  244. // this.purchaseAmountModVis = false
  245. this.close()
  246. },
  247. // 弹框查询按钮
  248. searchQuery() {
  249. this.purchaseAmountData = this.allDataList.filter(e=> this.queryParam.ccode == null || e.ccode.toLowerCase().indexOf(this.queryParam.ccode.toLowerCase())>-1);
  250. },
  251. // 重置
  252. searchReset() {
  253. this.queryParam.title = ''
  254. this.queryParam.isRelease = ''
  255. // this.getShipmentList()
  256. },
  257. close() {
  258. this.$emit('close')
  259. this.purchaseAmountModVis = false
  260. },
  261. showTotal(data) {
  262. return (
  263. <a-table
  264. ref="tableInfo"
  265. rowKey={Math.random}
  266. bordered={false}
  267. pagination={false}
  268. columns={this.purchaseAmountColumns}
  269. dataSource={this.totalDataSource || []}
  270. showHeader={false}
  271. scroll={{x:1500 }}
  272. ></a-table>
  273. )
  274. },
  275. // 导出excel
  276. exportExcel(){
  277. this.$refs.realExportExcel.$el.click();
  278. },
  279. // 生成导出数据
  280. getExportDataList(){
  281. this.purchaseAmountData.forEach((item,index)=>{item["ccode_ex"]="&nbsp;"+item["ccode"]});
  282. return this.purchaseAmountData;
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="less" scoped>
  288. @import '~@assets/less/common.less';
  289. @import '~@assets/less/overwriter.less';
  290. /deep/ .ant-table-thead > tr > th {
  291. text-align: center;
  292. // font-weight: 700;
  293. }
  294. /deep/ .ant-table-tbody {
  295. text-align: center;
  296. }
  297. /deep/ .ant-table-footer .ant-table-body {
  298. overflow: hidden !important;
  299. }
  300. // /deep/ th.replacecolor {
  301. // background-color: #ccc;
  302. // }
  303. </style>