byBill.vue 14 KB

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