index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <script setup lang="ts" name="StatementBill">
  2. import apis from "@a"
  3. import dayjs from "dayjs"
  4. import OrderSelect from "@@@/modal-select/OrderSelect.vue"
  5. const billStatusOptions = computed(() => {
  6. return [
  7. //{ label: "请选择", value: "" },
  8. { label: "已开票", value: "1" },
  9. { label: "未开票", value: "0" }
  10. ]
  11. })
  12. const isEdit = ref(false)
  13. const tableRef = ref()
  14. const modalRef = ref()
  15. const orderModalRef = ref()
  16. const opts = reactive({
  17. columns: [
  18. { field: "id", name: "", width: 100, isSort: true, visible: false, tooltip: true },
  19. {
  20. field: "orderNum",
  21. name: "订单号",
  22. visible: true,
  23. isSort: false,
  24. width: "auto",
  25. tooltip: true
  26. },
  27. {
  28. field: "price",
  29. name: "应收金额",
  30. visible: true,
  31. isSort: false,
  32. width: "auto",
  33. tooltip: true
  34. },
  35. {
  36. field: "actualPrice",
  37. name: "实收金额",
  38. visible: true,
  39. isSort: false,
  40. width: "auto",
  41. tooltip: true
  42. },
  43. {
  44. field: "billStatus",
  45. name: "是否开票",
  46. visible: true,
  47. isSort: false,
  48. width: "auto",
  49. tooltip: true
  50. },
  51. { field: "billDate", name: "开票日期", visible: true, isSort: false, width: 145 },
  52. {
  53. field: "billPrice",
  54. name: "发票金额",
  55. visible: true,
  56. isSort: false,
  57. width: "auto",
  58. tooltip: true
  59. },
  60. {
  61. field: "billFile",
  62. name: "发票pdf文件",
  63. visible: true,
  64. isSort: false,
  65. width: "auto",
  66. tooltip: true
  67. },
  68. { field: "remark", name: "备注", visible: true, isSort: false, tooltip: true },
  69. { field: "actions", name: `操作`, width: 150 }
  70. ] as any[],
  71. queryParams: {
  72. orderId: undefined,
  73. price: undefined,
  74. actualPrice: undefined,
  75. billStatus: undefined,
  76. dateRangeBillDate: undefined,
  77. billPrice: undefined,
  78. billFile: undefined
  79. },
  80. searchFormItems: [
  81. {
  82. field: "orderNum",
  83. label: "订单号",
  84. class: "w-100",
  85. required: false,
  86. placeholder: "请输入订单号",
  87. component: "I",
  88. listeners: {
  89. keyup: (e: KeyboardEvent) => {
  90. if (e.code == "Enter") {
  91. handleQuery()
  92. }
  93. }
  94. }
  95. },
  96. {
  97. field: "billStatus",
  98. label: "是否开票",
  99. class: "w-100",
  100. required: false,
  101. component: "VS",
  102. placeholder: "请选择是否开票",
  103. data: () => billStatusOptions.value,
  104. props: {
  105. valueIsNumber: 1,
  106. type: "select"
  107. },
  108. listeners: {
  109. change: () => {
  110. handleQuery()
  111. }
  112. }
  113. },
  114. {
  115. field: "dateRangeBillDate",
  116. label: "开票日期",
  117. class: "w-100",
  118. required: false,
  119. component: "D",
  120. placeholder: "请选择开票日期",
  121. props: {
  122. type: "daterange",
  123. valueFormat: "YYYY-MM-DD",
  124. rangeSeparator: "-",
  125. startPlaceholder: "开始日期",
  126. endPlaceholder: "结束日期"
  127. },
  128. listeners: {
  129. change: (v: any) => {
  130. queryParams.value.dateRangeBillDate = v
  131. handleQuery()
  132. }
  133. },
  134. span: 5
  135. }
  136. ] as any,
  137. permission: "erp:statementBill",
  138. handleBtns: [],
  139. handleFuns: {
  140. handleCreate,
  141. handleUpdate: () => {
  142. const row = tableRef.value.getSelected()
  143. handleUpdate(row)
  144. },
  145. handleDelete: () => {
  146. const rows = tableRef.value.getSelecteds()
  147. handleDelete(rows)
  148. }
  149. },
  150. customBtns: [],
  151. tableListFun: apis.erp.statementBillApi.list,
  152. getEntityFun: apis.erp.statementBillApi.get,
  153. deleteEntityFun: apis.erp.statementBillApi.del,
  154. exportUrl: apis.erp.statementBillApi.exportUrl,
  155. exportName: "StatementBill",
  156. modalTitle: "对账单信息",
  157. formItems: [
  158. {
  159. field: "orderNum",
  160. label: "订单编号",
  161. class: "w-100",
  162. required: true,
  163. placeholder: "请输入",
  164. component: "I",
  165. disabled: true,
  166. appendClickFunc: handleShowOrderModal,
  167. appendDisabled: () => isEdit.value
  168. },
  169. {
  170. field: "price",
  171. label: "应收",
  172. class: "w-100",
  173. required: true,
  174. placeholder: "请输入应收",
  175. component: "I"
  176. },
  177. {
  178. field: "actualPrice",
  179. label: "实收",
  180. class: "w-100",
  181. required: true,
  182. placeholder: "请输入实收",
  183. component: "I"
  184. },
  185. {
  186. field: "billStatus",
  187. label: "是否开票",
  188. class: "w-100",
  189. required: true,
  190. component: "VS",
  191. data: () => billStatusOptions.value,
  192. props: {
  193. type: "radio",
  194. valueIsNumber: 1
  195. }
  196. },
  197. {
  198. field: "billDate",
  199. label: "开票日期",
  200. class: "w-100",
  201. required: false,
  202. component: "D",
  203. props: {
  204. placeholder: "请选择开票日期",
  205. type: "date",
  206. valueFormat: "YYYY-MM-DD"
  207. }
  208. },
  209. {
  210. field: "billPrice",
  211. label: "发票金额",
  212. class: "w-100",
  213. required: true,
  214. placeholder: "请输入发票金额",
  215. component: "I"
  216. },
  217. {
  218. field: "billFile",
  219. label: "发票pdf文件",
  220. class: "w-100",
  221. required: false,
  222. component: "VbUpload",
  223. props: {
  224. uploadUrl: "resource/oss/upload/erp"
  225. }
  226. },
  227. {
  228. field: "remark",
  229. label: "备注",
  230. class: "w-100",
  231. required: false,
  232. placeholder: "请输入备注",
  233. component: "I",
  234. props: {
  235. type: "textarea",
  236. rows: 5
  237. }
  238. }
  239. ] as any,
  240. resetForm: () => {
  241. form.value = emptyFormData.value
  242. },
  243. labelWidth: "80px",
  244. emptyFormData: {
  245. id: undefined,
  246. orderId: undefined,
  247. orderNum: undefined,
  248. price: undefined,
  249. actualPrice: undefined,
  250. billStatus: 0,
  251. billDate: undefined,
  252. billPrice: undefined,
  253. billFile: undefined,
  254. remark: undefined
  255. }
  256. })
  257. const { queryParams, emptyFormData } = toRefs(opts)
  258. const form = ref<any>(emptyFormData.value)
  259. /** 搜索按钮操作 */
  260. function handleQuery(query?: any) {
  261. query = query || tableRef.value?.getQueryParams() || queryParams.value
  262. addDateRange(query, query.dateRangeBillDate, "BillDate")
  263. addDateRange(query, query.dateRangeCreateTime)
  264. addDateRange(query, query.dateRangeUpdateTime, "UpdateTime")
  265. tableRef.value?.query(query)
  266. }
  267. /** 重置按钮操作 */
  268. function resetQuery(query?: any) {
  269. query = query || tableRef.value?.getQueryParams() || queryParams.value
  270. query.dateRangeBillDate = [] as any
  271. addDateRange(query, query.dateRangeBillDate, "BillDate")
  272. query.dateRangeCreateTime = [] as any
  273. addDateRange(query, query.dateRangeCreateTime)
  274. query.dateRangeUpdateTime = [] as any
  275. addDateRange(query, query.dateRangeUpdateTime, "UpdateTime")
  276. //
  277. }
  278. function handleShowOrderModal() {
  279. orderModalRef.value.open()
  280. }
  281. function handleConfirmOrderModal(rows: any[]) {
  282. if (rows.length > 0) {
  283. form.value.orderId = rows[0].id
  284. form.value.orderNum = rows[0].orderNum
  285. }
  286. }
  287. function handleCreate() {
  288. tableRef.value.defaultHandleFuns.handleCreate()
  289. }
  290. /** 修改按钮操作 */
  291. function handleUpdate(row: any) {
  292. tableRef.value.defaultHandleFuns.handleUpdate("", row)
  293. }
  294. /** 删除按钮操作 */
  295. function handleDelete(rows: any[]) {
  296. tableRef.value.defaultHandleFuns.handleDelete("", rows)
  297. }
  298. /** 提交按钮 */
  299. function submitForm() {
  300. apis.erp.statementBillApi.addOrUpdate(form.value).then(() => {
  301. handleQuery()
  302. })
  303. }
  304. </script>
  305. <template>
  306. <div class="app-container">
  307. <VbDataTable
  308. ref="tableRef"
  309. keyField="id"
  310. :columns="opts.columns"
  311. :handle-perm="opts.permission"
  312. :handle-btns="opts.handleBtns"
  313. :handle-funs="opts.handleFuns"
  314. :search-form-items="opts.searchFormItems"
  315. :custom-btns="opts.customBtns"
  316. :remote-fun="opts.tableListFun"
  317. :get-entity-fun="opts.getEntityFun"
  318. :delete-entity-fun="opts.deleteEntityFun"
  319. :export-url="opts.exportUrl"
  320. :export-name="opts.exportName"
  321. :modal="modalRef"
  322. :reset-form-fun="opts.resetForm"
  323. v-model:form-data="form"
  324. v-model:query-params="queryParams"
  325. :check-multiple="true"
  326. :reset-search-form-fun="resetQuery"
  327. :custom-search-fun="handleQuery">
  328. <template #billStatus="{ row }">
  329. <VbTag :data="billStatusOptions" :value-is-number="1" :value="row.billStatus"></VbTag>
  330. </template>
  331. <template #billDate="{ row }">
  332. <template v-if="row.billDate">
  333. {{ dayjs(row.billDate).format("YYYY-MM-DD") }}
  334. </template>
  335. <template v-else>-</template>
  336. </template>
  337. <template #actions="{ row }">
  338. <vb-tooltip content="修改" placement="top">
  339. <el-button
  340. link
  341. type="primary"
  342. @click="handleUpdate(row)"
  343. v-hasPermission="'erp:statementBill:edit'">
  344. <template #icon>
  345. <VbIcon icon-name="notepad-edit" icon-type="duotone" class="fs-3"></VbIcon>
  346. </template>
  347. </el-button>
  348. </vb-tooltip>
  349. <vb-tooltip content="删除" placement="top">
  350. <el-button
  351. link
  352. type="primary"
  353. @click="handleDelete([row])"
  354. v-hasPermission="'erp:statementBill:remove'">
  355. <template #icon>
  356. <VbIcon icon-name="trash-square" icon-type="duotone" class="fs-3"></VbIcon>
  357. </template>
  358. </el-button>
  359. </vb-tooltip>
  360. </template>
  361. </VbDataTable>
  362. <VbModal
  363. v-model:modal="modalRef"
  364. :title="opts.modalTitle"
  365. :form-data="form"
  366. :form-items="opts.formItems"
  367. :label-width="opts.labelWidth"
  368. append-to-body
  369. @confirm="submitForm"></VbModal>
  370. <OrderSelect
  371. ref="orderModalRef"
  372. :multiple="false"
  373. @confirm="handleConfirmOrderModal"></OrderSelect>
  374. </div>
  375. </template>