contractClause.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <div>
  4. <div class="flex-align-center" style="margin-bottom:10px">
  5. <el-input size="small" style="width:200px;margin-right:10px" v-model="params.content.where.condition" placeholder="输入搜索内容" @clear="listData(params.content.pageNumber = 1)" @keyup.native.enter="listData(params.content.pageNumber = 1)" clearable></el-input>
  6. <slot name="addProduct"/>
  7. <el-popconfirm title="确定重置当前合同吗?" @confirm="reset()">
  8. <el-button size="small" slot="reference" class="inline-16" :disabled="disabled" v-if="tool.checkAuth($route.name,'resetContractClaus')">重 置</el-button>
  9. </el-popconfirm>
  10. </div>
  11. <tableLayout :layout="tablecols" :data="list" :opwidth="200" :width="false" height="calc(100vh - 550px)" :custom="true" fixedName="operation" >
  12. <template v-slot:customcol="scope">
  13. <div v-if="scope.column.columnname == 'content'">
  14. <el-input v-if="currentEdit.sa_contract_clauseid==scope.column.data.sa_contract_clauseid || scope.column.data.sa_contract_clauseid == 0" type="textarea" v-model="scope.column.data.content" size="small" placeholder="请输入条款"></el-input>
  15. <span v-else>{{scope.column.data[scope.column.columnname]}}</span>
  16. </div>
  17. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  18. </template>
  19. <template v-slot:opreation="scope">
  20. <el-button v-if="currentEdit.sa_contract_clauseid == scope.data.sa_contract_clauseid || scope.data.sa_contract_clauseid == 0" type="text" size="mini" @click="save(scope.data)" class="inline-16">保 存</el-button>
  21. <slot name="edit" :data="scope.data" v-else></slot>
  22. <slot name="del" :data="scope.data"></slot>
  23. </template>
  24. </tableLayout>
  25. </div>
  26. <div style="margin-top:16px;text-align:right">
  27. <el-pagination
  28. background
  29. small
  30. @size-change="handleSizeChange"
  31. @current-change="handleCurrentChange"
  32. :current-page="params.content.pageNumber"
  33. :page-size="params.content.pageSize"
  34. layout="total, prev, pager, next, jumper"
  35. :total="total">
  36. </el-pagination>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. export default {
  42. props:['disabled'],
  43. components: {},
  44. name: '',
  45. data() {
  46. return {
  47. list:[],
  48. params: {
  49. "id": 20221128162302,
  50. "content": {
  51. "sa_contractid":'',
  52. "pageNumber": 1,
  53. "pageSize": 20,
  54. "where": {
  55. "condition": ""
  56. }
  57. },
  58. },
  59. form: {
  60. discountrate:'',
  61. },
  62. tablecols:[],
  63. total:0,
  64. currentEdit:'',
  65. itemclassid:''
  66. };
  67. },
  68. computed:{
  69. },
  70. watch:{
  71. },
  72. created () {
  73. if (this.$route.query.id) this.listData()
  74. this.tablecols = this.tool.tabelCol(this.$route.name).clauseListTable.tablecols
  75. },
  76. methods: {
  77. async listData(){
  78. this.params.content.sa_contractid = this.$route.query.id
  79. const res = await this.$api.requested(this.params)
  80. this.list = res.data
  81. this.total = res.total
  82. console.log(this.list);
  83. },
  84. handleChange(num) {
  85. },
  86. async reset () {
  87. let res = await this.$api.requested({
  88. "id": 20221128161602,
  89. "content": {
  90. "sa_contractid":this.$route.query.id
  91. },
  92. })
  93. this.tool.showMessage(res,() => {
  94. this.listData()
  95. })
  96. },
  97. async save (data) {
  98. if(!data.content) {
  99. this.$message.error('条款内容不能为空');
  100. }else {
  101. let res = await this.$api.requested({
  102. "id": 20221128144502,
  103. "content": {
  104. "sa_contractid": this.$route.query.id,
  105. "items": [
  106. {
  107. "sa_contract_clauseid": data.sa_contract_clauseid,
  108. "content": data.content
  109. },
  110. ]
  111. },
  112. })
  113. this.tool.showMessage(res,() => {
  114. let index = this.list.findIndex(item => item == data)
  115. this.list[index] = res.data[0]
  116. this.currentEdit = {}
  117. console.log(this.list);
  118. this.$forceUpdate()
  119. })
  120. }
  121. },
  122. handleSizeChange(val) {
  123. // console.log(`每页 ${val} 条`);
  124. this.params.content.pageSize = val
  125. },
  126. handleCurrentChange(val) {
  127. // console.log(`当前页: ${val}`);
  128. this.params.content.pageNumber = val
  129. },
  130. },
  131. };
  132. </script>
  133. <style scoped>
  134. </style>