byBill.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <div class="bill">
  3. <div class="bill-left">
  4. <div class="bill-tab" :style="{width:closeTab?0:'200px'}">
  5. <div class="bill-title">导航</div>
  6. <div class="bill-nav" v-if="sourceConfig" :class="{'onBill':showTab == 'source'}" @click="tabChange('source')">引单</div>
  7. <div class="bill-nav" v-if="billConfig" :class="{'onBill':showTab == 'bill'}" @click="tabChange('bill')">单据</div>
  8. <div class="bill-nav" v-if="smtConfig" :class="{'onBill':showTab == 'smt'}" @click="tabChange('smt')">已提交</div>
  9. <div class="bill-nav" v-if="draftsBoxConfig" :class="{'onBill':showTab == 'draftsBox'}" @click="tabChange('draftsBox')">草稿箱</div>
  10. <div class="bill-nav" v-if="allConfig" :class="{'onBill':showTab == 'all'}" @click="tabChange('all')">综合查询</div>
  11. <div class="bill-nav" v-if="recycleBinConfig" :class="{'onBill':showTab == 'recycleBin'}" @click="tabChange('recycleBin')">回收站</div>
  12. <div class="bill-nav" v-for="(item,index) of customs" :class="{'onBill':showTab == item.name}" @click="tabChange(item.name)" :key="index">{{item.label}}</div>
  13. </div>
  14. <div class="close" @click="closeTab = !closeTab">
  15. <i class="el-icon-back" v-if="!closeTab"></i>
  16. <i class="el-icon-right" v-if="closeTab"></i>
  17. </div>
  18. </div>
  19. <div class="bill-main">
  20. <!-- 引单 -->
  21. <div class="bill-box" v-if="sourceConfig" :class="{'on-show':showTab == 'source'}">
  22. <el-tabs v-model="activeSource">
  23. <el-tab-pane v-for="(item,index) of sourceConfig" :key="index" :label="item.title" :name="'source'+index">
  24. <bill-module :propConfig="item" :ref="'source_'+index" @clickHandle="clickHandle($event,'source_'+index)" @search="search($event,'source_'+index)"
  25. @resert="resert('source_'+index)" @pagination="paginationChange($event,'source_'+index)" @detail="detail($event,'source_'+index)" />
  26. </el-tab-pane>
  27. </el-tabs>
  28. </div>
  29. <!-- 单据 -->
  30. <div class="bill-box" v-if="billConfig" :class="{'on-show':showTab == 'bill'}">
  31. <div class="bill-tool" v-if="billConfig.tool">
  32. <by-tool ref="billTool" :propConfig="billConfig.tool" @clickHandle="clickHandle($event,'bill')" />
  33. </div>
  34. <div class="form" v-if="billConfig.form">
  35. <by-form ref="billForm" :propConfig="billConfig.form" @getSupplierModal="getSupplierModal" />
  36. </div>
  37. <template v-if="billConfig.tableConfig && billConfig.tableConfig.length > 0">
  38. <div class="bill-table" v-for="(item,index) of billConfig.tableConfig" :key="index">
  39. <div class="table-title" v-if="item.title">{{ item.title }}</div>
  40. <div class="table-tool" v-if="item.tool">
  41. <by-tool :ref="'tableTool_'+index" :propConfig="item.tool" @clickHandle="clickHandle($event,'billTable_'+index)" />
  42. </div>
  43. <div class="table" v-if="item.table">
  44. <by-table :propConfig="item.table" :ref="'billTable_'+index" @onChangeRow="onChangeRow" />
  45. </div>
  46. </div>
  47. </template>
  48. </div>
  49. <!-- 已提交 -->
  50. <div class="bill-box" v-if="smtConfig" :class="{'on-show':showTab == 'smt'}">
  51. <bill-module :propConfig="smtConfig" ref="smt" @clickHandle="clickHandle($event,'smt')" @search="search($event,'smt')"
  52. @resert="resert('smt')" @pagination="paginationChange($event,'smt')" @detail="detail($event,'smt')" />
  53. </div>
  54. <!-- 草稿箱 -->
  55. <div class="bill-box" v-if="draftsBoxConfig" :class="{'on-show':showTab == 'draftsBox'}">
  56. <bill-module :propConfig="draftsBoxConfig" ref="draftsBox" @clickHandle="clickHandle($event,'draftsBox')" @search="search($event,'draftsBox')"
  57. @resert="resert('draftsBox')" @pagination="paginationChange($event,'draftsBox')" @detail="detail($event,'draftsBox')" />
  58. </div>
  59. <!-- 综合查询 -->
  60. <div class="bill-box" v-if="allConfig" :class="{'on-show':showTab == 'all'}">
  61. <bill-module :propConfig="allConfig" ref="all" @clickHandle="clickHandle($event,'all')" @search="search($event,'all')"
  62. @resert="resert('all')" @pagination="paginationChange($event,'all')" @detail="detail($event,'all')" />
  63. </div>
  64. <!-- 回收站 -->
  65. <div class="bill-box" v-if="recycleBinConfig" :class="{'on-show':showTab == 'recycleBin'}">
  66. <bill-module :propConfig="recycleBinConfig" ref="recycleBin" @clickHandle="clickHandle($event,'recycleBin')" @search="search($event,'recycleBin')"
  67. @resert="resert('recycleBin')" @pagination="paginationChange($event,'recycleBin')" @detail="detail($event,'recycleBin')" />
  68. </div>
  69. <!-- 插槽 -->
  70. <div class="bill-box" v-for="(item,index) of customs" :key="index" :class="{'on-show':showTab == item.name}">
  71. <slot :name='item.name'></slot>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script lang="ts">
  77. /**
  78. config:{
  79. attr:{
  80. activeName:'' //tabs标签值
  81. },
  82. source:[ //引单
  83. {
  84. title:'', //标题
  85. search:{}, //表单配置
  86. tool:{}, //工具栏配置
  87. table:{} //表格配置
  88. }
  89. ],
  90. bill:{ //单据
  91. form:{}, //表单配置
  92. tool:{}, //工具栏配置
  93. tableConfig:[ //表格配置
  94. {
  95. title:'',
  96. tool:{} //表格工具栏
  97. table:{}
  98. }
  99. ]
  100. },
  101. smt:{ //已提交
  102. search:{}, //表单配置
  103. tool:{}, //工具栏配置
  104. table:{} //表格配置
  105. },
  106. draftsBox:{ //草稿箱
  107. search:{}, //表单配置
  108. tool:{}, //工具栏配置
  109. table:{} //表格配置
  110. },
  111. all:{}, //综合查询(配置同上)
  112. recycleBin:{} //回收站(配置同上)
  113. }
  114. */
  115. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  116. import VueViews from '@/benyun/compVue/VueViews'
  117. import billModule from "./billModule.vue";
  118. @Component({components:{billModule}})
  119. export default class ByBill extends VueViews {
  120. showTab="bill"
  121. closeTab = false
  122. activeSource='source0'
  123. //引单
  124. get sourceConfig(){
  125. return this.config?.source ? this.config.source : null;
  126. }
  127. //单据配置
  128. get billConfig(){
  129. return this.config?.bill ? this.config.bill : null;
  130. }
  131. //已提交配置
  132. get smtConfig(){
  133. return this.config?.smt ? this.config.smt : null;
  134. }
  135. //草稿箱配置
  136. get draftsBoxConfig(){
  137. return this.config?.draftsBox ? this.config.draftsBox : null;
  138. }
  139. //综合查询配置
  140. get allConfig(){
  141. return this.config?.all ? this.config.all : null;
  142. }
  143. //回收站配置
  144. get recycleBinConfig(){
  145. return this.config?.recycleBin ? this.config.recycleBin : null;
  146. }
  147. //自定义插槽
  148. get customs(){
  149. return this.config?.customs ? this.config.customs : []
  150. }
  151. created(){
  152. if(this.propConfig){
  153. this.setConfig(this.propConfig)
  154. }
  155. }
  156. setConfigAfter(){
  157. if(this.attrs.activeName){
  158. this.showTab = this.attrs.activeName
  159. }
  160. }
  161. //设置单据内表单和表格配置
  162. setBillConfig(c:any){
  163. if(c){
  164. this.config.bill = c;
  165. this.$nextTick(()=>{
  166. if(c.form){
  167. (this.$refs.billForm as any).setConfig(c.form)
  168. }
  169. if(this.$refs.billTool){
  170. (this.$refs.billTool as any).initTools()
  171. }
  172. if(c?.tableConfig?.length > 0){
  173. let n = 0;
  174. for(const item of c.tableConfig){
  175. if(this.$refs['tableTool_'+n]){
  176. (this.$refs['tableTool_'+n] as any)[0].initTools();
  177. }
  178. if(item.table && this.$refs['billTable_'+n]){
  179. (this.$refs['billTable_'+n] as any)[0].setConfig(item.table)
  180. }
  181. n++;
  182. }
  183. }
  184. })
  185. }
  186. }
  187. //左侧tab切换
  188. tabChange(t:string){
  189. this.showTab = t;
  190. this.$emit('clickTab',t)
  191. }
  192. //工具栏
  193. /**
  194. *
  195. * @param n1 方法
  196. * @param n2 表示哪个表格的操作
  197. */
  198. clickHandle(n1:string,n2:string){
  199. this.$emit(n1,n2)
  200. }
  201. search(v:any,n:string){
  202. this.$emit('search',{
  203. type:n,
  204. value:v
  205. })
  206. }
  207. resert(n:string){
  208. this.$emit('resert',{
  209. type:n
  210. })
  211. }
  212. //设置引单表格数据
  213. setSourceTableData(n:any,data:Array<any>){
  214. const code = 'source_'+n;
  215. if(this.$refs[code]){
  216. (this.$refs[code] as any)[0]?.setTableValue(data)
  217. }
  218. }
  219. //获取引单表格数据
  220. getSourceTableData(n:any){
  221. let d:Array<any>=[];
  222. const code = 'source_'+n;
  223. if(this.$refs[code]){
  224. d = (this.$refs[code] as any)[0]?.getTableValue()
  225. }
  226. }
  227. //获取引单表格选中数据
  228. getSourceTableSelectData(n:any){
  229. let d:Array<any>=[];
  230. const code = 'source_'+n;
  231. if(this.$refs[code]){
  232. d = (this.$refs[code] as any)[0]?.getTableValue()
  233. }
  234. return d;
  235. }
  236. //获取引单搜索数据
  237. getSourceSearchData(n:any){
  238. let d:any = {};
  239. const code = 'source_'+n;
  240. if(this.$refs[code]){
  241. d = (this.$refs[code] as any)[0]?.getSearchValue()
  242. }
  243. return d;
  244. }
  245. //设置引单分页
  246. setSourcePage(n:any,page:any){
  247. const code = 'source_'+n;
  248. if(this.$refs[code]){
  249. (this.$refs[code] as any)[0]?.setPage(page)
  250. }
  251. }
  252. //获取表格数据
  253. getTableData(n:string){
  254. let d:Array<any> = [];
  255. if(this.$refs[n]){
  256. d = (this.$refs[n] as any).getTableValue()
  257. }
  258. return d;
  259. }
  260. //获取表格选中数据
  261. getTableSelectData(n:string){
  262. let d:Array<any> = [];
  263. if(this.$refs[n]){
  264. d = (this.$refs[n] as any).getSelectTable()
  265. }
  266. return d;
  267. }
  268. //获取搜索数据
  269. getSearchValue(n:string){
  270. let d:any = {};
  271. if(this.$refs[n]){
  272. d = (this.$refs[n] as any).getSearchValue()
  273. }
  274. return d;
  275. }
  276. //获取单据数据
  277. getBillFormValue(){
  278. let v = (this.$refs.billForm as any).getValue();
  279. return v;
  280. }
  281. onChangeRow(row:any){
  282. this.$emit('onChangeRow',row);
  283. }
  284. //获取单据表格已选数据
  285. /**
  286. *
  287. * @param n 表示第几个单据表格,用下标表示
  288. */
  289. getBillTableSelect(n:any){
  290. let d:Array<any>=[];
  291. const code = 'billTable_'+n;
  292. if(this.$refs[code]){
  293. d = (this.$refs[code] as any)[0].getSelectData();
  294. }
  295. return d;
  296. }
  297. //设置单据表单数据
  298. setBillFormValue(value:any){
  299. if(this.$refs['billForm']){
  300. (this.$refs['billForm'] as any).setValue(value)
  301. }
  302. }
  303. //设置单据表格数据
  304. /**
  305. *
  306. * @param value 表格值
  307. * @param n 表示第几个表格,一般是下标值
  308. */
  309. setBillTableValue(value:any,n:number){
  310. let code = 'billTable_'+n;
  311. if(this.$refs[code]){
  312. (this.$refs[code] as any)[0].setValue(value);
  313. }
  314. }
  315. //设置tab表格数据
  316. /**
  317. *
  318. * @param n
  319. * @param data
  320. */
  321. setTabTableValue(n:string,data:Array<any>){
  322. if(this.$refs[n]){
  323. (this.$refs[n] as any).setTableValue(data);
  324. }
  325. }
  326. /**
  327. *
  328. * @param n
  329. * @param page
  330. */
  331. //设置tab表格分页
  332. setTablePage(n:string,page:any){
  333. if(this.$refs[n]){
  334. (this.$refs[n] as any).setPage(page);
  335. }
  336. }
  337. //分页变化
  338. paginationChange(page:any,n:string){
  339. this.$emit('pagination',{page,type:n})
  340. }
  341. detail(row:any,n:string){
  342. this.$emit('detail',{row,type:n})
  343. }
  344. getSupplierModal(e:any){
  345. this.$emit('getSupplierModal',e);
  346. }
  347. }
  348. </script>
  349. <style lang="scss" scoped>
  350. .bill{
  351. width: 100%;
  352. box-sizing: border-box;
  353. display: flex;
  354. padding: 16px;
  355. .bill-left {
  356. position: relative;
  357. border-right: solid #EEE 1px;
  358. padding-right:16px;
  359. flex-shrink: 0;
  360. // box-sizing: border-box;
  361. .bill-tab{
  362. width: 200px;
  363. height: 100%;
  364. transition: all .5s;
  365. overflow: hidden;
  366. }
  367. .bill-title{
  368. font-size: 16px;
  369. padding-bottom: 16px;
  370. width: 200px;
  371. }
  372. .bill-nav{
  373. font-size: 14px;
  374. height: 30px;
  375. line-height: 30px;
  376. width: 200px;
  377. box-sizing: border-box;
  378. padding: 0 8px;
  379. cursor: pointer;
  380. margin-bottom: 2px;
  381. border-radius: 5px;
  382. }
  383. .onBill{
  384. background-color: #bde3f7;
  385. }
  386. .bill-nav:hover{
  387. background-color: #bde3f7;
  388. }
  389. .close{
  390. height: 22px;
  391. width: 22px;
  392. border-radius: 50%;
  393. border: solid #EEE 1px;
  394. position: absolute;
  395. top: 30px;
  396. right: -11px;
  397. background-color: #FFF;
  398. display: flex;
  399. justify-content: center;
  400. align-items: center;
  401. cursor: pointer;
  402. }
  403. }
  404. .bill-main{
  405. width: calc(100% - 16px);
  406. box-sizing: border-box;
  407. margin-left: 16px;
  408. position: relative;
  409. .bill-box{
  410. width: 100%;
  411. position: absolute;
  412. left: 0;
  413. top: 0;
  414. opacity: 0;
  415. z-index: -1;
  416. transition: all .5s;
  417. .bill-table{
  418. padding-bottom: 16px;
  419. width: 100%;
  420. .table-title{
  421. font-size: 14px;
  422. padding-bottom: 8px;
  423. }
  424. }
  425. .bill-table:last-child{
  426. padding: 0;
  427. }
  428. .bill-tool,.table-tool{
  429. width: 100%;
  430. padding-bottom: 16px;
  431. }
  432. .form{
  433. margin-bottom: 8px;
  434. }
  435. }
  436. .on-show{
  437. opacity: 1;
  438. z-index: 1;
  439. }
  440. }
  441. }
  442. </style>