index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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" :data="list" :custom="true" :width="true" fixedName="writeoffamount unwriteoffamount operation" >
  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>{{'¥ '+ tool.formatAmount(scope.column.data.writeoffamount,2)}}</span>
  23. </div>
  24. <span v-else-if="scope.column.columnname == 'unwriteoffamount'">
  25. {{'¥ '+ tool.formatAmount(scope.column.data.unwriteoffamount,2)}}
  26. </span>
  27. <span v-else-if="scope.column.columnname == 'price'">
  28. {{'¥ '+ tool.formatAmount(scope.column.data.price,2)}}
  29. </span>
  30. <span v-else-if="scope.column.columnname == 'amounts'">
  31. {{'¥ '+ tool.formatAmount(scope.column.data.amount,2)}}
  32. </span>
  33. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  34. <p v-if="!scope.column.data[scope.column.columnname] && scope.column.data[scope.column.columnname] !== 0 && scope.column.columnname != 'operation' && scope.column.columnname != 'amounts'" >--</p>
  35. </template>
  36. <template v-slot:opreation="scope">
  37. <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>
  38. <slot name="editOrder" :data="scope.data" v-else></slot>
  39. <slot name="delOrder" :data="scope.data"></slot>
  40. </template>
  41. </tableLayout>
  42. </div>
  43. <div style="margin-top:16px;text-align:right">
  44. <el-pagination
  45. background
  46. small
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :current-page="params.content.pageNumber"
  50. :page-size="params.content.pageSize"
  51. layout="total, prev, pager, next, jumper"
  52. :total="total">
  53. </el-pagination>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import { log } from '@antv/g2plot/lib/utils'
  59. import tableLayout from '@/components/dynamic-table/index2'
  60. export default {
  61. props:["data"],
  62. components:{tableLayout},
  63. data () {
  64. return {
  65. tablecols:[],
  66. list:[],
  67. total:0,
  68. search:'',
  69. params:{
  70. "id": 20221208091504,
  71. "version": 1,
  72. "content": {
  73. "nocache": true,
  74. "pageNumber": 1,
  75. "pageSize":20,
  76. "sa_writeoffbillid": '',
  77. "where": {
  78. "condition": ""
  79. }
  80. },
  81. },
  82. options:[
  83. ],
  84. productList:'',
  85. /* 当前正在编辑的数据信息 */
  86. currentItem:''
  87. }
  88. },
  89. provide () {
  90. return {
  91. }
  92. },
  93. methods:{
  94. async save (data) {
  95. if (typeof +data.writeoffamount != 'number') return this.$message({
  96. title:'提示',
  97. message:'请输入数字'
  98. })
  99. let res = await this.$api.requested({
  100. "id":20221124090904,
  101. "content": {
  102. sa_writeoffbillid:this.$route.query.id,
  103. writeoffbillOrder: [
  104. {
  105. "sa_writeoffbill_orderid": data.sa_writeoffbill_orderid,
  106. "sa_orderid":data.sa_orderid,
  107. "sa_orderitemsid":data.sa_orderitemsid,
  108. "writeoffamount":data.writeoffamount,
  109. "remarks":""
  110. }
  111. ]
  112. }
  113. })
  114. console.log(res);
  115. this.tool.showMessage(res,() => {
  116. this.$emit('onSuccess')
  117. this.listData()
  118. this.currentItem = ''
  119. })
  120. },
  121. async listData(){
  122. this.params.content.sa_writeoffbillid = this.$route.query.id
  123. const res = await this.$api.requested(this.params)
  124. this.list = res.data
  125. this.total = res.total
  126. },
  127. handleSizeChange(val) {
  128. // console.log(`每页 ${val} 条`);
  129. this.params.content.pageSize = val
  130. this.listData()
  131. },
  132. handleCurrentChange(val) {
  133. // console.log(`当前页: ${val}`);
  134. this.params.content.pageNumber = val
  135. this.listData()
  136. },
  137. clearData(){
  138. this.search = ""
  139. this.params.content.where.condition = this.search
  140. this.listData()
  141. },
  142. queryClick(){
  143. this.params.content.where.condition = this.search
  144. this.listData()
  145. }
  146. },
  147. created() {
  148. this.listData()
  149. console.log(this.$route.name)
  150. this.tablecols = this.tool.tabelCol(this.$route.name).writeOffOrderTable.tablecols
  151. }
  152. }
  153. </script>
  154. <style scoped>
  155. </style>