bill.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div>
  3. <by-bill :propConfig="config" @search="search" @onSmt="onSmt" ref="bill" @onAdd="onAdd">
  4. <template v-slot:cus>我是插槽</template>
  5. </by-bill>
  6. <div style="clear: both;"></div>
  7. <div>
  8. <el-button type="primary" plain @click="setSmtValue">设置已提交数据</el-button><br/>
  9. <el-button type="primary" plain @click="setdraftsBoxValue">设置草稿箱数据</el-button>
  10. </div>
  11. </div>
  12. </template>
  13. <script lang="ts">
  14. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  15. @Component
  16. export default class BillDemo extends Vue {
  17. config:any={
  18. bill:{
  19. tool:{
  20. tools:{
  21. add:true,
  22. edit:true
  23. }
  24. },
  25. form:{
  26. attr:{
  27. size:'small'
  28. },
  29. columns:[
  30. [{
  31. span:6,
  32. label:'创建时间',
  33. prop:'created',
  34. component:'by-date-picker',
  35. compConfig:{
  36. format:'yyyy-MM-dd HH:mm:ss',
  37. type:'datetime'
  38. }
  39. }]
  40. ]
  41. },
  42. tableTool:{
  43. tools:{
  44. add:true
  45. }
  46. },
  47. table:{
  48. attr:{
  49. size:'mini',
  50. height:240,
  51. seq:true,
  52. align:'center',
  53. checkbox:true
  54. },
  55. columns:[{
  56. title:'id',
  57. field:'id',
  58. width:50
  59. },
  60. {
  61. title:'姓名',
  62. field:'name',
  63. width:100
  64. },{
  65. title:'操作',
  66. action:true,
  67. plugins:[{
  68. icon:'el-icon-edit',
  69. name:'编辑',
  70. audit:'',
  71. event:{
  72. click:(item:any) => {
  73. console.log('该行数据:',item)
  74. }
  75. }
  76. }]
  77. }]
  78. }
  79. },
  80. smt:{
  81. search:{
  82. attr:{
  83. size:'mini',
  84. rules:{
  85. name:[{
  86. required: true, message: '请输入名称', trigger: 'blur'
  87. }]
  88. }
  89. },
  90. columns:[
  91. [{
  92. span:6,
  93. label:'创建时间',
  94. prop:'created',
  95. component:'by-date-picker',
  96. compConfig:{
  97. format:'yyyy-MM-dd',
  98. type:'datetime'
  99. }
  100. }]
  101. ]
  102. },
  103. tool:{
  104. tools:{
  105. smt:true,
  106. export:true,
  107. search:true,
  108. refresh:true
  109. }
  110. },
  111. table:{
  112. attr:{
  113. size:'mini',
  114. seq:true,
  115. align:'center',
  116. checkbox:true
  117. },
  118. columns:[{
  119. title:'id',
  120. field:'id',
  121. width:50
  122. },
  123. {
  124. title:'姓名',
  125. field:'name',
  126. width:100
  127. },
  128. {
  129. title:'日期',
  130. field:'time',
  131. // width:200
  132. }]
  133. }
  134. },
  135. draftsBox:{
  136. search:{
  137. attr:{
  138. size:'mini',
  139. rules:{
  140. name:[{
  141. required: true, message: '请输入名称', trigger: 'blur'
  142. }]
  143. }
  144. },
  145. columns:[
  146. [{
  147. span:6,
  148. label:'名称',
  149. prop:'name',
  150. component:'by-input'
  151. }]
  152. ]
  153. },
  154. tool:{
  155. tools:{
  156. smt:true,
  157. export:true,
  158. search:true,
  159. refresh:true
  160. }
  161. },
  162. table:{
  163. attr:{
  164. size:'mini',
  165. seq:true,
  166. align:'center',
  167. checkbox:true
  168. },
  169. columns:[
  170. {
  171. title:'姓名',
  172. field:'name',
  173. width:100
  174. },
  175. {
  176. title:'日期',
  177. field:'time',
  178. // width:200
  179. }]
  180. }
  181. },
  182. customs:[{
  183. label:'自定义',
  184. name:'cus'
  185. }]
  186. }
  187. search(parames:any){
  188. console.log('搜索回传参数',parames);
  189. }
  190. onSmt(n:string){
  191. console.log(n+':工具栏执行操作onSmt')
  192. }
  193. onAdd(n:string){
  194. console.log(n);
  195. }
  196. setSmtValue(){
  197. let data:Array<any>=[{
  198. id:1,
  199. name:'张三',
  200. time:'2023-02-02'
  201. },{
  202. id:2,
  203. name:'李四',
  204. time:'2023-02-02'
  205. }];
  206. (this.$refs.bill as any).setTabTableValue('smt',data);
  207. }
  208. setdraftsBoxValue(){
  209. let data:Array<any>=[{
  210. name:'王五',
  211. time:'2023-02-02'
  212. },{
  213. name:'赵六',
  214. time:'2023-02-02'
  215. }];
  216. (this.$refs.bill as any).setTabTableValue('draftsBox',data);
  217. }
  218. }
  219. </script>