tab-invoice.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <span class="mr-2">发票类型:</span>
  5. <el-button _icon hc-btn size="small" type="primary" @click="positionEdit(1)">
  6. <HcIcon name="add"/>
  7. </el-button>
  8. </template>
  9. <HcTable :column="positiontableColumn" :datas="positiontableData" :loading="tableLoaing">
  10. <template #action="{row, index}">
  11. <el-button size="small" type="primary" @click="positionEdit(2,row)">编辑</el-button>
  12. <el-button size="small" type="primary" @click="delTaskposition(row)">删除</el-button>
  13. </template>
  14. </HcTable>
  15. <HcDialog bgColor="#ffffff" isToBody widths="24rem" :show="positonModal" :title="positonModalTitle" @close="positonModalClose" @save="savepositionClick">
  16. <el-form label-position="top" label-width="auto" :model="formposition" size="large">
  17. <el-form-item label="发票类型名称:">
  18. <el-input v-model="formposition.dictName"/>
  19. </el-form-item>
  20. </el-form>
  21. </HcDialog>
  22. </HcCard>
  23. </template>
  24. <script setup>
  25. import {ref, watch,onMounted} from "vue";
  26. import {submitDictionary,removeDictionary,getParentList,getChildList} from '~api/system/parameter.js';
  27. import {getArrValue} from "js-fast-way"
  28. const props = defineProps({
  29. cur: {
  30. type: [String,Number],
  31. default: ''
  32. },
  33. type:{
  34. type: [String,Number],
  35. default: ''
  36. }
  37. })
  38. const tabsKey = ref(props.cur)
  39. const tabsType = ref(props.type)
  40. //监听
  41. watch(() => [
  42. props.cur,
  43. props.type,
  44. ], ([key,type]) => {
  45. tabsKey.value = key
  46. tabsType.value = type
  47. })
  48. onMounted(() => {
  49. getParentListData()
  50. })
  51. const tableLoaing=ref(false)
  52. const getParentListData=async()=>{
  53. tableLoaing.value=true
  54. const { error, code, data,msg } = await getParentList({
  55. type:tabsType.value,
  56. })
  57. tableLoaing.value=false
  58. if (!error && code === 200) {
  59. positiontableData.value = getArrValue(data['records'])
  60. }
  61. else {
  62. positiontableData.value=[]
  63. window.$message?.warning(msg)
  64. }
  65. }
  66. const positiontableColumn = [
  67. {key: 'dictName', name: '报销类型名称'},
  68. {key: 'action', name: '操作', width: 200}
  69. ]
  70. const positiontableData = ref([
  71. ])
  72. const positonModal = ref(false)
  73. const positonModalTitle = ref('')
  74. const editItem=ref({})
  75. const positionEdit = (type,row) => {
  76. if (type === 1) {
  77. positonModalTitle.value = '新增报销类型'
  78. formposition.value={}
  79. editItem.value={}
  80. } else {
  81. positonModalTitle.value = '编辑报销类型'
  82. editItem.value=row
  83. formposition.value=row
  84. }
  85. positonModal.value = true
  86. }
  87. const positonModalClose = () => {
  88. positonModal.value = false
  89. }
  90. const formposition = ref({})
  91. //新增编辑提交
  92. const savepositionClick=async()=>{
  93. const { error, code, data,msg } = await submitDictionary({
  94. type:tabsType.value,
  95. dictValue:formposition.value?.dictValue,
  96. dictName:formposition.value?.dictName,
  97. id:editItem.value.id||null
  98. })
  99. positonModal.value=false
  100. if (!error && code === 200) {
  101. window.$message?.success(msg)
  102. getParentListData()
  103. }
  104. else {
  105. window.$message?.warning(msg)
  106. }
  107. }
  108. const delTaskposition = (row) => {
  109. window?.$messageBox?.alert('您确定要删除该信息吗? 一旦注销数据将彻底清除,请谨慎操作?', '删除提醒', {
  110. showCancelButton: true,
  111. confirmButtonText: '确认注销',
  112. cancelButtonText: '取消',
  113. type: 'warning',
  114. callback: async(action) => {
  115. if (action === 'confirm') {
  116. const {error, code, msg} = await removeDictionary({
  117. ids: row?.id,
  118. })
  119. if (!error && code === 200) {
  120. window?.$message?.success('删除成功')
  121. getParentListData()
  122. } else {
  123. window?.$message?.warning(msg)
  124. }
  125. }
  126. }
  127. })
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. </style>