materialsOutQuantityModal.vue 9.8 KB

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