DialogContractChoice.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <el-dialog v-model="visible" width="680px" append-to-body draggable :close-on-click-modal = "false">
  3. <template #header>
  4. <div class="dialog-title-container">
  5. <span class="title-label" style="color: white"><i class="el-icon-document" style="color: white" /> 合同选择</span>
  6. <i class="el-icon-close" @click="close" />
  7. </div>
  8. </template>
  9. <!-- 功能按钮 -->
  10. <div v-if="multiple" class="form-btns-container">
  11. <el-button type="success" size="small" @click="handleMultipleSelected"><i class="fa fa-floppy-o"
  12. aria-hidden="true" /> 确定选择</el-button>
  13. </div>
  14. <div class="dialog-list-container">
  15. <el-table :data="list" size="small" border height="400px" header-row-class-name="list-header-row"
  16. row-class-name="list-row" @selection-change="handleSelectionChange">
  17. <el-table-column v-if="multiple" type="selection" width="40" align="center" />
  18. <el-table-column type="index" label="序号" width="46" align="center" />
  19. <el-table-column label="合同编号" prop="contractNo" width="100" align="center" />
  20. <el-table-column label="客户名称" prop="companyName" width="100" align="center" />
  21. <el-table-column label="备注" prop="remark" header-align="center" />
  22. <el-table-column v-if="!multiple" label="操作" width="50" align="center">
  23. <template #default="scope">
  24. <el-button link type="success" size="small" @click="handleSimpleSelected(scope.row)">选择</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. </div>
  29. <!-- <div class="pagination-container"> -->
  30. <pagination v-show="query.total > 0" :total="query.total" v-model:page="query.pageNum" v-model:limit="query.pageSize"
  31. @pagination="getList" style="background-color: rgba(0, 0, 0, 0);" />
  32. <!-- </div> -->
  33. </el-dialog>
  34. </template>
  35. <script setup>
  36. import { toRef } from 'vue'
  37. import { listContract } from '@/api/business/financial/payment'
  38. const props = defineProps({
  39. width: {
  40. type: String,
  41. default: '800px'
  42. },
  43. multiple: {
  44. type: Boolean,
  45. default: () => false
  46. }
  47. })
  48. const emit = defineEmits(['choice']);
  49. const { width, multiple } = toRefs(props)
  50. const data = reactive({
  51. visible: false,
  52. query: {
  53. pageNum: 1,
  54. pageSize: 15,
  55. total: 0
  56. },
  57. list: [],
  58. selections: [],
  59. options: {}
  60. })
  61. const { visible, query, list, selections, options } = toRefs(data)
  62. function open(input) {
  63. visible.value = true;
  64. options.value = input == null ? {} : input
  65. getList()
  66. }
  67. function close() {
  68. visible.value = false;
  69. }
  70. const getList = () => {
  71. listContract({ ...query.value, ...options.value })
  72. .then(res => {
  73. query.value.total = res.total
  74. list.value = res.rows
  75. }).catch(err => {
  76. console.log(err)
  77. })
  78. }
  79. const handleMultipleSelected = () => {
  80. emit('choice', selections.value)
  81. close()
  82. }
  83. const handleSimpleSelected = (row) => {
  84. emit('choice', row)
  85. close()
  86. }
  87. const handleSelectionChange = (choiceSelections) => {
  88. selections.value = choiceSelections
  89. }
  90. // getList()
  91. defineExpose({
  92. open,
  93. close
  94. })
  95. </script>