MemorandumManageSettingDialog.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <el-dialog
  3. :modal="true"
  4. :close-on-click-modal="false"
  5. :close-on-press-escape="false"
  6. destroy-on-close
  7. title="备忘录"
  8. :model-value="dialogVisible"
  9. :before-close="handleClose"
  10. >
  11. <diy-el-form ref="formDialogRef" class="form" :forms="MemorandumManageFormConfig" v-model:model-form="form">
  12. <template #sltappend>
  13. <el-upload
  14. :limit="2"
  15. ref="upload"
  16. :show-file-list="false"
  17. class="my-el-upload"
  18. :on-change="onChange"
  19. :auto-upload="false"
  20. >
  21. <el-button class="upload-btn" size="small" type="primary">{{form.FILENAME}}</el-button>
  22. </el-upload>
  23. </template>
  24. </diy-el-form>
  25. <template v-if="dialogOperationType != 'detail'" #footer>
  26. <el-button :icon="SuccessFilled" @click="conform">确定</el-button>
  27. <el-button @click="handleClose" :icon="Close">取消</el-button>
  28. </template>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. import {Close, Delete, Edit, Plus, SuccessFilled} from "@element-plus/icons-vue";
  33. import DiyElForm from "@/components/common/DiyElForm.vue";
  34. import {computed, onBeforeMount, ref} from "vue";
  35. import {MemorandumManageForm} from "@/data/all-form";
  36. import {elAlert, handleMes} from "@/units/element-ui/tip";
  37. import axios from "axios";
  38. import {
  39. proInsertXyxxBwl,
  40. proUpdateXyxxBwl
  41. } from "@/service/policy-and-regulation-manage/memorandum-manage/memorandum-manage";
  42. import {InsertSyslog} from "@/units/use-method/user-log";
  43. export default {
  44. name: "MemorandumManageSettingDialog",
  45. components:{DiyElForm},
  46. computed: {
  47. Delete() {
  48. return Delete
  49. },
  50. Edit() {
  51. return Edit
  52. },
  53. Plus() {
  54. return Plus
  55. },
  56. SuccessFilled() {
  57. return SuccessFilled
  58. },
  59. Close() {
  60. return Close
  61. }
  62. },
  63. props:{
  64. dialogVisible:{ //是否可见
  65. },
  66. dialogOperationType:{ //操作类型
  67. },
  68. currentDialogObj:{ //当前选中信息
  69. },
  70. },
  71. setup(props,{emit}){
  72. const form = ref({}); //表单内容-值
  73. const formDialogRef =ref(null); //表单ref
  74. const file = ref(null);
  75. const MemorandumManageFormConfig = ref({...MemorandumManageForm}); //表单配置项
  76. onBeforeMount(() =>{
  77. MemorandumManageFormConfig.value.formAttrs.disabled=props.dialogOperationType === 'detail';
  78. form.value = {
  79. ...props.currentDialogObj
  80. }
  81. form.value.slt = props.currentDialogObj.NAME;
  82. })
  83. function onChange(files){
  84. debugger
  85. file.value = files;
  86. form.value.slt=files.name;
  87. form.value.FILENAME = files.name;
  88. }
  89. function conform(){
  90. formDialogRef.value.refEl.validate(isValid => {
  91. if (isValid){
  92. debugger
  93. if(!props.currentDialogObj.CODE){
  94. let month = new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
  95. let strDate = new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate();
  96. let time4 = new Date().getFullYear() + "-" + month + "-" + strDate;
  97. let suffixName = file.value.name.substring(file.value.name.lastIndexOf(".")); //后缀名称
  98. let fileName = form.value.NAME + time4;
  99. debugger
  100. let formData = new FormData();
  101. formData.append("file",file.value.raw);
  102. formData.append("fileName",fileName + suffixName);
  103. formData.append("type","bwl")
  104. axios.post('http://localhost:8081/upload/xypt',formData,{'Content-type':'multipart/form-data'}).then(res =>{
  105. console.log(res);
  106. if(res.data[0].success=='true'){
  107. insertBwl(fileName,suffixName)
  108. }else{
  109. elAlert("文件上传失败")
  110. }
  111. })
  112. }else{
  113. updateBwl()
  114. }
  115. }
  116. })
  117. }
  118. function insertBwl(fileName,suffixName){
  119. proInsertXyxxBwl({
  120. wenhao: form.value.WENHAO,
  121. name: form.value.NAME,
  122. username: localStorage.getItem("xyxx_username"),
  123. suffixName: suffixName,
  124. fileName: fileName,
  125. }).then(res =>{
  126. handleMes(res,() => {
  127. emit('getTableData');
  128. InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"),"信息新增", "备忘录管理新增成功", "备忘录管理", "")
  129. handleClose()
  130. })
  131. })
  132. }
  133. function updateBwl(){
  134. proUpdateXyxxBwl({
  135. code:props.currentDialogObj.CODE,
  136. wenhao: form.value.WENHAO,
  137. name: form.value.NAME,
  138. suffixName: "",
  139. fileName: "",
  140. }).then(res =>{
  141. handleMes(res,() => {
  142. emit('getTableData');
  143. InsertSyslog(localStorage.getItem("xyxx_usercode"),localStorage.getItem("xyxx_unitcode"),"信息修改", "备忘录管理修改成功", "备忘录管理", "")
  144. handleClose()
  145. })
  146. })
  147. }
  148. function handleClose(){
  149. emit('update:dialogVisible',false);
  150. }
  151. return {
  152. form,
  153. formDialogRef,
  154. MemorandumManageFormConfig,
  155. conform,
  156. handleClose,
  157. onChange
  158. }
  159. }
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. :deep{
  164. .el-button>span{
  165. width: 100%;
  166. height: 100%;
  167. float: left !important;
  168. overflow: hidden;
  169. text-overflow: ellipsis;
  170. }
  171. .el-button--small{
  172. padding: 1px 11px;
  173. }
  174. }
  175. </style>