editPrint.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div class="sys-print-container">
  3. <div class="printDialog">
  4. <el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" fullscreen>
  5. <template #header>
  6. <div style="color: #fff">
  7. <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
  8. <span> {{ props.title }} </span>
  9. </div>
  10. </template>
  11. <div style="margin: -16px 0px 0px 0px">
  12. <HiprintDesign ref="hiprintDesignRef" />
  13. </div>
  14. <template #footer>
  15. <span class="dialog-footer" style="margin-top: 10px">
  16. <el-button @click="cancel">取 消</el-button>
  17. <el-button type="primary" @click="submit">保存模板</el-button>
  18. </span>
  19. </template>
  20. </el-dialog>
  21. </div>
  22. <el-dialog v-model="state.showDialog2" draggable :close-on-click-modal="false" width="600px">
  23. <template #header>
  24. <div style="color: #fff">
  25. <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>
  26. <span>{{ props.title }}</span>
  27. </div>
  28. </template>
  29. <el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
  30. <el-row :gutter="35">
  31. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  32. <el-form-item label="模板名称" prop="name" :rules="[{ required: true, message: '模板名称不能为空', trigger: 'blur' }]">
  33. <el-input v-model="state.ruleForm.name" placeholder="模板名称" clearable />
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  37. <el-form-item label="排序">
  38. <el-input-number v-model="state.ruleForm.orderNo" placeholder="排序" class="w100" />
  39. </el-form-item>
  40. </el-col>
  41. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  42. <el-form-item label="状态">
  43. <el-radio-group v-model="state.ruleForm.status">
  44. <el-radio :value="1">启用</el-radio>
  45. <el-radio :value="2">禁用</el-radio>
  46. </el-radio-group>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
  50. <el-form-item label="打印类型">
  51. <el-radio-group v-model="state.ruleForm.printType">
  52. <el-radio :value="1">浏览器打印</el-radio>
  53. <el-radio :value="2">客户端打印</el-radio>
  54. </el-radio-group>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  58. <el-form-item label="客户端服务地址" >
  59. <el-input v-model="state.ruleForm.clientServiceAddress" placeholder="客户端服务地址" clearable />
  60. </el-form-item>
  61. </el-col>
  62. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  63. <el-form-item label="打印参数">
  64. <el-input v-model="state.ruleForm.printParam" placeholder="请输入打印参数" clearable type="textarea" />
  65. </el-form-item>
  66. </el-col>
  67. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  68. <el-form-item label="备注">
  69. <el-input v-model="state.ruleForm.remark" placeholder="请输入备注内容" clearable type="textarea" />
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. </el-form>
  74. <template #footer>
  75. <span class="dialog-footer">
  76. <el-button @click="templateCancel">取 消</el-button>
  77. <el-button type="primary" @click="templateSubmit">确 定</el-button>
  78. </span>
  79. </template>
  80. </el-dialog>
  81. </div>
  82. </template>
  83. <script lang="ts" setup name="sysEditPrint">
  84. import { onMounted, reactive, ref, nextTick } from 'vue';
  85. import HiprintDesign from '/@/views/system/print/component/hiprint/index.vue';
  86. import { getAPI } from '/@/utils/axios-utils';
  87. import { SysPrintApi } from '/@/api-services/api';
  88. import { UpdatePrintInput } from '/@/api-services/models';
  89. const hiprintDesignRef = ref<InstanceType<typeof HiprintDesign>>();
  90. const props = defineProps({
  91. title: String,
  92. });
  93. const emits = defineEmits(['handleQuery']);
  94. const ruleFormRef = ref();
  95. const state = reactive({
  96. isShowDialog: false,
  97. ruleForm: {} as UpdatePrintInput,
  98. showDialog2: false,
  99. });
  100. onMounted(async () => {});
  101. // 打开弹窗
  102. const openDialog = (row: any) => {
  103. state.ruleForm = JSON.parse(JSON.stringify(row));
  104. state.isShowDialog = true;
  105. ruleFormRef.value?.resetFields();
  106. nextTick(() => {
  107. loadTemplate();
  108. });
  109. };
  110. // 加载模板
  111. const loadTemplate = () => {
  112. hiprintDesignRef.value?.hiprintTemplate.clear();
  113. if (JSON.stringify(state.ruleForm) !== '{}') {
  114. hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
  115. }
  116. };
  117. // 取消
  118. const cancel = () => {
  119. state.isShowDialog = false;
  120. };
  121. // 提交
  122. const submit = async () => {
  123. state.showDialog2 = true;
  124. if (state.ruleForm.orderNo == undefined) state.ruleForm.orderNo = 100;
  125. if (state.ruleForm.status == undefined) state.ruleForm.status = 1;
  126. if (state.ruleForm.printType == undefined) state.ruleForm.printType = 1;
  127. };
  128. // 模板设置取消
  129. const templateCancel = () => {
  130. state.showDialog2 = false;
  131. };
  132. // 模板设置提交
  133. const templateSubmit = async () => {
  134. state.ruleForm.template = JSON.stringify(hiprintDesignRef.value?.hiprintTemplate.getJson());
  135. if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
  136. await getAPI(SysPrintApi).apiSysPrintUpdatePost(state.ruleForm);
  137. } else {
  138. await getAPI(SysPrintApi).apiSysPrintAddPost(state.ruleForm);
  139. }
  140. cancel();
  141. templateCancel();
  142. emits('handleQuery');
  143. };
  144. // 导出对象
  145. defineExpose({ openDialog });
  146. </script>
  147. <style lang="scss" scoped>
  148. .printDialog {
  149. :deep(.el-dialog) {
  150. .el-dialog__header {
  151. display: none !important;
  152. }
  153. .el-dialog__body {
  154. max-height: calc(100vh - 80px) !important;
  155. }
  156. }
  157. }
  158. </style>