byBill.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="bill">
  3. <div class="bill-left">
  4. <div class="bill-tab" :style="{width:closeTab?0:'200px'}">
  5. <div class="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" />
  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" />
  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. if(c.form){
  166. (this.$refs.billForm as any).setConfig(c.form)
  167. }
  168. if(c?.tableConfig?.length > 0){
  169. let n = 0;
  170. for(const item of c.tableConfig){
  171. if(item.table && this.$refs['billTable_'+n]){
  172. (this.$refs['billTable_'+n] as any)[0].setConfig(item.table)
  173. }
  174. n++;
  175. }
  176. }
  177. }
  178. }
  179. //左侧tab切换
  180. tabChange(t:string){
  181. this.showTab = t;
  182. }
  183. //工具栏
  184. /**
  185. *
  186. * @param n1 方法
  187. * @param n2 表示哪个表格的操作
  188. */
  189. clickHandle(n1:string,n2:string){
  190. this.$emit(n1,n2)
  191. }
  192. search(v:any,n:string){
  193. this.$emit('search',{
  194. type:n,
  195. value:v
  196. })
  197. }
  198. resert(n:string){
  199. this.$emit('resert',{
  200. type:n
  201. })
  202. }
  203. //设置引单表格数据
  204. setSourceTableData(n:any,data:Array<any>){
  205. const code = 'source_'+n;
  206. if(this.$refs[code]){
  207. (this.$refs[code] as any)[0]?.setTableValue(data)
  208. }
  209. }
  210. //获取引单表格数据
  211. getSourceTableData(n:any){
  212. let d:Array<any>=[];
  213. const code = 'source_'+n;
  214. if(this.$refs[code]){
  215. d = (this.$refs[code] as any)[0]?.getTableValue()
  216. }
  217. }
  218. //获取引单表格选中数据
  219. getSourceTableSelectData(n:any){
  220. let d:Array<any>=[];
  221. const code = 'source_'+n;
  222. if(this.$refs[code]){
  223. d = (this.$refs[code] as any)[0]?.getTableValue()
  224. }
  225. return d;
  226. }
  227. //获取引单搜索数据
  228. getSourceSearchData(n:any){
  229. let d:any = {};
  230. const code = 'source_'+n;
  231. if(this.$refs[code]){
  232. d = (this.$refs[code] as any)[0]?.getSearchValue()
  233. }
  234. return d;
  235. }
  236. //设置引单分页
  237. setSourcePage(n:any,page:any){
  238. const code = 'source_'+n;
  239. if(this.$refs[code]){
  240. (this.$refs[code] as any)[0]?.setPage(page)
  241. }
  242. }
  243. //获取表格数据
  244. getTableData(n:string){
  245. let d:Array<any> = [];
  246. if(this.$refs[n]){
  247. d = (this.$refs[n] as any).getTableValue()
  248. }
  249. return d;
  250. }
  251. //获取表格选中数据
  252. getTableSelectData(n:string){
  253. let d:Array<any> = [];
  254. if(this.$refs[n]){
  255. d = (this.$refs[n] as any).getTableValue()
  256. }
  257. return d;
  258. }
  259. //获取搜索数据
  260. getSearchValue(n:string){
  261. let d:any = {};
  262. if(this.$refs[n]){
  263. d = (this.$refs[n] as any).getSearchValue()
  264. }
  265. return d;
  266. }
  267. //获取单据数据
  268. getBillFormValue(){
  269. let v = (this.$refs.billForm as any).getValue();
  270. return v;
  271. }
  272. //获取单据表格已选数据
  273. /**
  274. *
  275. * @param n 表示第几个单据表格,用下标表示
  276. */
  277. getBillTableSelect(n:any){
  278. let d:Array<any>=[];
  279. const code = 'billTable_'+n;
  280. if(this.$refs[code]){
  281. d = (this.$refs[code] as any)[0].getSelectData();
  282. }
  283. return d;
  284. }
  285. //设置单据表单数据
  286. setBillFormValue(value:any){
  287. if(this.$refs['billForm']){
  288. (this.$refs['billForm'] as any).setValue(value)
  289. }
  290. }
  291. //设置单据表格数据
  292. /**
  293. *
  294. * @param value 表格值
  295. * @param n 表示第几个表格,一般是下标值
  296. */
  297. setBillTableValue(value:any,n:number){
  298. let code = 'billTable_'+n;
  299. if(this.$refs[code]){
  300. (this.$refs[code] as any)[0].setValue(value);
  301. }
  302. }
  303. //设置tab表格数据
  304. /**
  305. *
  306. * @param n
  307. * @param data
  308. */
  309. setTabTableValue(n:string,data:Array<any>){
  310. if(this.$refs[n]){
  311. (this.$refs[n] as any).setTableValue(data);
  312. }
  313. }
  314. /**
  315. *
  316. * @param n
  317. * @param page
  318. */
  319. //设置tab表格分页
  320. setTablePage(n:string,page:any){
  321. if(this.$refs[n]){
  322. (this.$refs[n] as any).setPage(page);
  323. }
  324. }
  325. //分页变化
  326. paginationChange(page:any,n:string){
  327. this.$emit('pagination',{page,type:n})
  328. }
  329. detail(row:any,n:string){
  330. this.$emit('detail',{row,type:n})
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. .bill{
  336. width: 100%;
  337. box-sizing: border-box;
  338. display: flex;
  339. padding: 16px;
  340. .bill-left {
  341. position: relative;
  342. border-right: solid #EEE 1px;
  343. padding-right:16px;
  344. flex-shrink: 0;
  345. // box-sizing: border-box;
  346. .bill-tab{
  347. width: 200px;
  348. height: 100%;
  349. transition: all .5s;
  350. overflow: hidden;
  351. }
  352. .title{
  353. font-size: 16px;
  354. padding-bottom: 16px;
  355. width: 200px;
  356. }
  357. .bill-nav{
  358. font-size: 14px;
  359. height: 30px;
  360. line-height: 30px;
  361. width: 200px;
  362. box-sizing: border-box;
  363. padding: 0 8px;
  364. cursor: pointer;
  365. margin-bottom: 2px;
  366. border-radius: 5px;
  367. }
  368. .onBill{
  369. background-color: #bde3f7;
  370. }
  371. .bill-nav:hover{
  372. background-color: #bde3f7;
  373. }
  374. .close{
  375. height: 22px;
  376. width: 22px;
  377. border-radius: 50%;
  378. border: solid #EEE 1px;
  379. position: absolute;
  380. top: 30px;
  381. right: -11px;
  382. background-color: #FFF;
  383. display: flex;
  384. justify-content: center;
  385. align-items: center;
  386. cursor: pointer;
  387. }
  388. }
  389. .bill-main{
  390. width: calc(100% - 16px);
  391. box-sizing: border-box;
  392. margin-left: 16px;
  393. position: relative;
  394. .bill-box{
  395. width: 100%;
  396. position: absolute;
  397. left: 0;
  398. top: 0;
  399. opacity: 0;
  400. z-index: -1;
  401. transition: all .5s;
  402. .bill-table{
  403. padding-bottom: 16px;
  404. width: 100%;
  405. .table-title{
  406. font-size: 14px;
  407. padding-bottom: 8px;
  408. }
  409. }
  410. .bill-table:last-child{
  411. padding: 0;
  412. }
  413. .bill-tool,.table-tool{
  414. width: 100%;
  415. padding-bottom: 16px;
  416. }
  417. .form{
  418. margin-bottom: 8px;
  419. }
  420. }
  421. .on-show{
  422. opacity: 1;
  423. z-index: 1;
  424. }
  425. }
  426. }
  427. </style>