dialog.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <style scoped lang="scss">
  2. </style>
  3. <template>
  4. <div class="system-dialog-container">
  5. <el-dialog
  6. :title="state.dialog.title"
  7. v-model="state.dialog.isShowDialog"
  8. width="820px"
  9. draggable
  10. destroy-on-close
  11. :close-on-click-modal="false"
  12. @close="onClose"
  13. align-center>
  14. <el-form
  15. inline
  16. :model="state.ruleForm"
  17. :rules="state.rules"
  18. ref="formRef"
  19. size="default"
  20. label-width="125px"
  21. class="mt5">
  22. <el-form-item label="微信发票申请id" prop="applyId">
  23. <el-input
  24. v-model.trim="state.ruleForm.applyId"
  25. placeholder="微信发票申请号"
  26. readonly
  27. class="wd200">
  28. </el-input>
  29. </el-form-item>
  30. <el-form-item label="开票日期" prop="fapiaoTime">
  31. <el-input
  32. v-model.trim="state.ruleForm.fapiaoTime"
  33. readonly
  34. class="wd200">
  35. </el-input>
  36. </el-form-item>
  37. <!-- <el-form-item label="用户id" prop="userId">
  38. <el-input
  39. v-model.trim="state.ruleForm.userId"
  40. placeholder="用户id"
  41. readonly
  42. class="wd200">
  43. </el-input>
  44. </el-form-item>-->
  45. <el-form-item label="累积充电量(度)" prop="totalPower">
  46. <el-input
  47. v-model.trim="state.detail.totalPower"
  48. placeholder="累积充电量(度)"
  49. readonly
  50. class="wd200">
  51. </el-input>
  52. </el-form-item>
  53. <el-form-item label="累积总金额(元)" prop="totalMoney">
  54. <el-input
  55. :model-value="u.fmt.fmtMoney(state.detail.totalMoney)"
  56. placeholder="累积总金额(元)"
  57. readonly
  58. class="wd200">
  59. </el-input>
  60. </el-form-item>
  61. <el-form-item label="累积电费(元)" prop="elecMoney">
  62. <el-input
  63. :model-value="u.fmt.fmtMoney(state.detail.elecMoney)"
  64. placeholder="累积电费(元)"
  65. readonly
  66. class="wd200">
  67. </el-input>
  68. </el-form-item>
  69. <el-form-item label="累积服务费(元)" prop="serviceMoney">
  70. <el-input
  71. :model-value="u.fmt.fmtMoney(state.detail.serviceMoney)"
  72. placeholder="累积服务费(元)"
  73. readonly
  74. class="wd200">
  75. </el-input>
  76. </el-form-item>
  77. <el-form-item label="服务费优惠金额(元)" prop="serviceMoneyDiscount">
  78. <el-input
  79. :model-value="u.fmt.fmtMoney(state.detail.serviceMoneyDiscount)"
  80. placeholder="服务费优惠金额(元)"
  81. readonly
  82. class="wd200">
  83. </el-input>
  84. </el-form-item>
  85. <el-form-item label="接收发票邮箱" prop="email">
  86. <el-input
  87. v-model.trim="state.ruleForm.email"
  88. placeholder="接收发票邮箱"
  89. readonly
  90. class="wd200">
  91. </el-input>
  92. </el-form-item>
  93. <el-form-item label="电话" prop="phone">
  94. <el-input
  95. v-model.trim="state.ruleForm.phone"
  96. placeholder="电话"
  97. readonly
  98. class="wd200">
  99. </el-input>
  100. </el-form-item>
  101. <el-form-item label="发票类型" prop="invoiceType">
  102. <ext-d-label class="wd200" type="Invoice.type" :model-value="state.ruleForm.buyerInformation.type"></ext-d-label>
  103. </el-form-item>
  104. <el-form-item label="发票抬头名称" prop="invoiceTitle">
  105. <el-input
  106. v-model.trim="state.ruleForm.buyerInformation.name"
  107. placeholder="发票抬头名称"
  108. readonly
  109. class="wd200">
  110. </el-input>
  111. </el-form-item>
  112. <el-form-item label="公司税号" prop="taxId">
  113. <el-input
  114. v-model.trim="state.ruleForm.buyerInformation.taxpayer_id"
  115. placeholder="公司税号"
  116. readonly
  117. class="wd200">
  118. </el-input>
  119. </el-form-item>
  120. <el-form-item label="公司地址" prop="address">
  121. <el-input
  122. v-model.trim="state.ruleForm.buyerInformation.address"
  123. placeholder="公司地址"
  124. readonly
  125. class="wd200">
  126. </el-input>
  127. </el-form-item>
  128. <el-form-item label="开户银行" prop="bankName">
  129. <el-input
  130. v-model.trim="state.ruleForm.buyerInformation.bank_name"
  131. placeholder="开户银行"
  132. readonly
  133. class="wd200">
  134. </el-input>
  135. </el-form-item>
  136. <el-form-item label="银行账户" prop="bankAccount">
  137. <el-input
  138. v-model.trim="state.ruleForm.buyerInformation.bank_account"
  139. placeholder="银行账户"
  140. readonly
  141. class="wd200">
  142. </el-input>
  143. </el-form-item>
  144. <el-form-item label="发票金额(单位:分)" prop="invoiceAmount">
  145. <el-input
  146. :model-value="u.fmt.fmtMoney(state.ruleForm.totalAmount)"
  147. placeholder="发票金额(单位:分)"
  148. readonly
  149. class="wd200">
  150. </el-input>
  151. </el-form-item>
  152. <el-form-item label="税额" prop="taxInfo">
  153. <el-input
  154. :model-value="u.fmt.fmtMoney(state.ruleForm.taxAmount)"
  155. placeholder="税额"
  156. readonly
  157. class="wd200">
  158. </el-input>
  159. </el-form-item>
  160. <el-form-item label="开票人" prop="biller">
  161. <el-input
  162. v-model.trim="state.ruleForm.sellerInformation.name"
  163. placeholder="开票人"
  164. readonly
  165. class="wd200">
  166. </el-input>
  167. </el-form-item>
  168. <el-form-item label="发票状态" prop="status">
  169. <ext-d-label class="wd200" type="Invoice.status" :model-value="state.ruleForm.status"> </ext-d-label>
  170. </el-form-item>
  171. <!-- <el-form-item label="备注" prop="remark">
  172. <el-input
  173. v-model.trim="state.ruleForm.remark"
  174. placeholder="备注"
  175. readonly
  176. class="wd200">
  177. </el-input>
  178. </el-form-item>-->
  179. </el-form>
  180. <template #footer>
  181. <div class="dialog-footer">
  182. <el-button @click="onCancel" size="default">取 消</el-button>
  183. <el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
  184. </div>
  185. </template>
  186. </el-dialog>
  187. </div>
  188. </template>
  189. <script setup lang="ts" name="InvoiceDialog">
  190. import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
  191. import {Msg} from "/@/utils/message";
  192. import {$body, $get} from "/@/utils/request";
  193. import u from '/@/utils/u'
  194. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  195. // 定义子组件向父组件传值/事件
  196. const emit = defineEmits(['refresh']);
  197. const formRef = ref();
  198. //定义初始变量,重置使用
  199. const initState = () => ({
  200. ruleForm: {
  201. id: 0,
  202. buyerInformation:{},
  203. blueFapiao:{},
  204. cardInformation:{},
  205. extraInformationd:{},
  206. sellerInformation:{},
  207. },
  208. detail:{
  209. orderDetails:{}
  210. },
  211. btnLoading: false,
  212. dialog: {
  213. isShowDialog: false,
  214. type: '',
  215. title: '',
  216. submitTxt: '',
  217. },
  218. rules: {},
  219. })
  220. // 定义变量内容
  221. const state = reactive(initState());
  222. // 打开弹窗
  223. const open = (action: string = 'add', row: any) => {
  224. state.dialog.title = u.dialog.actions[action].title + "『发票记录表』"
  225. state.dialog.submitTxt = u.dialog.actions[action].btn + "『发票记录表』"
  226. state.dialog.isShowDialog = true;
  227. state.detail = row;
  228. if (action !== 'add') {
  229. loadData(row.applyId);
  230. } else {
  231. state.ruleForm = Object.assign(state.ruleForm, row);
  232. }
  233. };
  234. // 关闭弹窗
  235. const onClose = () => {
  236. state.dialog.isShowDialog = false;
  237. Object.assign(state, initState())
  238. };
  239. // 取消
  240. const onCancel = () => {
  241. onClose();
  242. };
  243. // 提交
  244. const onSubmit = () => {
  245. formRef.value.validate((valid: boolean) => {
  246. if (valid) {
  247. state.btnLoading = true;
  248. const url = state.ruleForm.id > 0 ? "invoice/modify" : "invoice/add"
  249. $body(url, state.ruleForm).then(() => {
  250. state.btnLoading = false;
  251. Msg.message('操作成功');
  252. console.log('submit!')
  253. onClose();
  254. emit('refresh');
  255. })
  256. }
  257. }).catch(() => {
  258. state.btnLoading = false;
  259. Msg.message('请先完整填写表单', 'error');
  260. })
  261. };
  262. const handleFormChange = (formData: any) => {
  263. console.log(formData)
  264. }
  265. // 初始化表格数据
  266. const loadData = (applyId: String) => {
  267. $get(`finance/listInvoiceDetail`, {applyId}).then((res: any) => {
  268. if (res.list && res.list.length > 0) {
  269. state.ruleForm = res.list[0];
  270. console.log(state.ruleForm)
  271. console.log(state.detail)
  272. }
  273. })
  274. }
  275. // 暴露变量
  276. defineExpose({
  277. open
  278. });
  279. </script>