index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div>
  3. <div style="display:flex;align-items:center">
  4. <el-input
  5. placeholder="请输入搜索内容"
  6. suffix-icon="el-icon-search"
  7. v-model="params.content.where.condition"
  8. style="width:200px"
  9. size="mini"
  10. class="input-with-select inline-16"
  11. @keyup.native.enter="listData(params.content.pageNumber=1)"
  12. @clear="clearData"
  13. clearable>
  14. </el-input>
  15. <slot name="addOrder"></slot>
  16. </div>
  17. <div style="margin-top: 15px">
  18. <tableLayout :layout="tablecols" height="400px" :data="list" :custom="true" :width="true" fixedName="operation writeoffamount unwriteoffamount">
  19. <template v-slot:customcol="scope">
  20. <div v-if="scope.column.columnname == 'writeoffamount'">
  21. <el-input size="small" v-if="currentItem.sa_writeoffbill_orderid == scope.column.data.sa_writeoffbill_orderid" v-model="scope.column.data.writeoffamount"></el-input>
  22. <span v-else>{{scope.column.data.writeoffamount}}</span>
  23. </div>
  24. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  25. <p v-if="!scope.column.data[scope.column.columnname] && scope.column.data[scope.column.columnname] !== 0 && scope.column.columnname != 'operation'">--</p>
  26. </template>
  27. <template v-slot:opreation="scope">
  28. <el-button class="inline-16" type="text" size="mini" @click="save(scope.data)" v-if="currentItem.sa_writeoffbill_orderid == scope.data.sa_writeoffbill_orderid">保 存</el-button>
  29. <slot name="editOrder" :data="scope.data" v-else></slot>
  30. <slot name="delOrder" :data="scope.data"></slot>
  31. </template>
  32. </tableLayout>
  33. </div>
  34. <div style="margin-top:16px;text-align:right">
  35. <el-pagination
  36. background
  37. small
  38. @size-change="handleSizeChange"
  39. @current-change="handleCurrentChange"
  40. :current-page="params.content.pageNumber"
  41. :page-size="params.content.pageSize"
  42. layout="total, prev, pager, next, jumper"
  43. :total="total">
  44. </el-pagination>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. import { log } from '@antv/g2plot/lib/utils'
  50. export default {
  51. props:["data"],
  52. data () {
  53. return {
  54. tablecols:[],
  55. list:[],
  56. total:0,
  57. search:'',
  58. params:{
  59. "id": 20221208091504,
  60. "version": 1,
  61. "content": {
  62. "nocache": true,
  63. "pageNumber": 1,
  64. "pageSize":20,
  65. "sa_writeoffbillid": '',
  66. "where": {
  67. "condition": ""
  68. }
  69. },
  70. },
  71. options:[
  72. ],
  73. productList:'',
  74. /* 当前正在编辑的数据信息 */
  75. currentItem:''
  76. }
  77. },
  78. provide () {
  79. return {
  80. }
  81. },
  82. methods:{
  83. async save (data) {
  84. if (typeof +data.writeoffamount != 'number') return this.$message({
  85. title:'提示',
  86. message:'请输入数字'
  87. })
  88. let res = await this.$api.requested({
  89. "id":20221124090904,
  90. "content": {
  91. sa_writeoffbillid:this.$route.query.id,
  92. writeoffbillOrder: [
  93. {
  94. "sa_writeoffbill_orderid": data.sa_writeoffbill_orderid,
  95. "sa_orderid":data.sa_orderid,
  96. "sa_orderitemsid":data.sa_orderitemsid,
  97. "writeoffamount":data.writeoffamount,
  98. "remarks":""
  99. }
  100. ]
  101. }
  102. })
  103. console.log(res);
  104. this.tool.showMessage(res,() => {
  105. this.$emit('onSuccess')
  106. this.listData()
  107. this.currentItem = ''
  108. })
  109. },
  110. async listData(){
  111. this.params.content.sa_writeoffbillid = this.$route.query.id
  112. const res = await this.$api.requested(this.params)
  113. this.list = res.data
  114. this.total = res.total
  115. console.log(this.list)
  116. },
  117. handleSizeChange(val) {
  118. // console.log(`每页 ${val} 条`);
  119. this.params.content.pageSize = val
  120. this.listData()
  121. },
  122. handleCurrentChange(val) {
  123. // console.log(`当前页: ${val}`);
  124. this.params.content.pageNumber = val
  125. this.listData()
  126. },
  127. clearData(){
  128. this.search = ""
  129. this.params.content.where.condition = this.search
  130. this.listData()
  131. },
  132. queryClick(){
  133. this.params.content.where.condition = this.search
  134. this.listData()
  135. }
  136. },
  137. created() {
  138. this.listData()
  139. this.tablecols = this.tool.tabelCol(this.$route.name).writeOffOrderTable.tablecols
  140. }
  141. }
  142. </script>
  143. <style scoped>
  144. </style>