detail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div style="background:#F1F2F3;height:100vh;box-sizing:border-box">
  3. <p class="normal-title normal-panel container">合同模板详情</p>
  4. <div class="content normal-panel">
  5. <div class="header container">
  6. <span class="title">{{type[$route.query.type]}}条款设置</span>
  7. <el-button size="small" type="primary" v-if="tool.checkAuth($route.name,'addClaue')" @click="addClause">添加</el-button>
  8. </div>
  9. <div class="container">
  10. <tableLayout v-if="show" :layout="tablecols" :data="list" :opwidth="200" :custom="true" height="calc(100vh - 250px)" >
  11. <template v-slot:customcol="scope">
  12. <div v-if="scope.column.columnname == 'content'">
  13. <el-input
  14. v-if="scope.column.data.sa_contract_template_clauseid == 0 || scope.column.data.sa_contract_template_clauseid == currentEdit.sa_contract_template_clauseid"
  15. v-model="scope.column.data.content" size="small"
  16. placeholder="请输入条款"
  17. type="textarea"
  18. ></el-input>
  19. <span v-else>{{scope.column.data[scope.column.columnname]}}</span>
  20. </div>
  21. <div v-else-if="scope.column.columnname == 'editable'">
  22. <el-checkbox
  23. v-if="currentEdit.sa_contract_template_clauseid!=scope.column.data.sa_contract_template_clauseid && scope.column.data.sa_contract_template_clauseid != 0"
  24. :disabled="true"
  25. :value="scope.column.data.editable"
  26. :true-label="1"
  27. :false-label="0">
  28. </el-checkbox>
  29. <el-checkbox
  30. v-else
  31. v-model="currentEdit.editable"
  32. :true-label="1"
  33. :false-label="0">
  34. </el-checkbox>
  35. </div>
  36. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  37. </template>
  38. <template v-slot:opreation="scope">
  39. <span class="inline-16">
  40. <el-button
  41. size="mini"
  42. type="text"
  43. @click="save(scope.data)"
  44. v-if="scope.data.sa_contract_template_clauseid == 0 || currentEdit.sa_contract_template_clauseid==scope.data.sa_contract_template_clauseid"
  45. >保 存</el-button>
  46. <el-button size="mini" type="text" @click="editBtn(scope.data)" v-else-if="tool.checkAuth($route.name,'editClaue')">编 辑</el-button>
  47. </span>
  48. <delete-btn v-if="tool.checkAuth($route.name,'delClaue')" message="确定删除当前条款吗?" nameId="20221125195702" :data="scope.data" @deleteSuccess="onDelete" :id="scope.data.sa_contract_template_clauseid" nameKey="sa_contract_template_clauseids"></delete-btn>
  49. </template>
  50. </tableLayout>
  51. <div style="margin-top:16px;text-align:right">
  52. <el-pagination
  53. background
  54. small
  55. @size-change="handleSizeChange"
  56. @current-change="handleCurrentChange"
  57. :current-page="params.content.pageNumber"
  58. :page-size="params.content.pageSize"
  59. layout="total, prev, pager, next, jumper"
  60. :total="total">
  61. </el-pagination>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. export default {
  69. name: '',
  70. data() {
  71. return {
  72. type:{
  73. 1:'直销项目协议',
  74. 2:'经销项目协议',
  75. 3:'经销商合作协议',
  76. 4:'居间协议',
  77. 5:'工具借用协议',
  78. },
  79. params: {
  80. "id": 20221125200102,
  81. "content": {
  82. "contracttype":'',
  83. "pageNumber": 1,
  84. "pageSize": 20,
  85. "where": {
  86. "condition": ""
  87. }
  88. },
  89. },
  90. total:0,
  91. tablecols:[],
  92. list:[],
  93. currentEdit:{},
  94. show:true
  95. };
  96. },
  97. computed:{
  98. },
  99. watch:{
  100. },
  101. created () {
  102. this.tablecols = this.tool.tabelCol(this.$route.name).clauseTable.tablecols
  103. this.listData()
  104. },
  105. methods: {
  106. /* 获取条款 */
  107. async listData () {
  108. this.params.content.contracttype = this.$route.query.type
  109. let res = await this.$api.requested(this.params)
  110. this.list = res.data
  111. this.total = res.total
  112. console.log(res);
  113. },
  114. addClause () {
  115. this.list.unshift({
  116. content:'',
  117. editable:1,
  118. sa_contract_template_clauseid:0
  119. })
  120. },
  121. editBtn (data) {
  122. this.currentEdit = data
  123. console.log(this.currentEdit);
  124. },
  125. async save (data) {
  126. if(!data.content) return
  127. let item = {
  128. content:data.content,
  129. editable:data.editable,
  130. sa_contract_template_clauseid:data.sa_contract_template_clauseid
  131. }
  132. let res = await this.$api.requested({
  133. "content": {
  134. "contracttype": this.$route.query.type,//1直销,2经销,3框架,4居间,5工具,
  135. "items": [item]
  136. },
  137. "id": 20221125194202,
  138. })
  139. this.tool.showMessage(res,() => {
  140. let index = this.list.findIndex(item => item == data)
  141. this.list[index] = res.data[0]
  142. this.$forceUpdate()
  143. this.currentEdit = {}
  144. })
  145. },
  146. onDelete (data) {
  147. this.list.splice(this.list.findIndex(item => item == data),1)
  148. },
  149. handleSizeChange(val) {
  150. // console.log(`每页 ${val} 条`);
  151. this.params.content.pageSize = val
  152. this.listData()
  153. },
  154. handleCurrentChange(val) {
  155. // console.log(`当前页: ${val}`);
  156. this.params.content.pageNumber = val
  157. this.listData()
  158. },
  159. },
  160. };
  161. </script>
  162. <style scoped>
  163. .title {
  164. font-size: 14px;
  165. margin-top: 10px;
  166. }
  167. .content {
  168. margin-top: 10px;
  169. height: calc(100vh - 66px);
  170. }
  171. .content .header{
  172. display: flex;
  173. justify-content: space-between;
  174. border-bottom: 1px solid #cccccc;
  175. }
  176. </style>