materialsOutQuantityModal.vue 13 KB

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