You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div>
  3. <crud-template :ref="(el) => (crudRef = el)" class="as-weight" :home-data="field" :table-data="tableData"
  4. @btnSearch="btnSearch" @generateAeport="generateAeport" @importData="importData" @refreshLeft="refreshLeft"
  5. @CurrentChange="handleCurrentChange" @download="downloadHandle" @pageSizeChange="(val) => {
  6. field.paging.currentPage = 1
  7. field.paging.pageSize = val
  8. getList()
  9. }">
  10. <template #search>
  11. <el-input maxlength="60" v-trim clearable v-model="searchForm.promotionChannels" style="width: 200px;"
  12. placeholder="请输入推广渠道" />
  13. <el-input maxlength="60" v-trim clearable v-model="searchForm.productType" style="width: 200px;"
  14. placeholder="请输入产品类型" />
  15. <!-- <el-select clearable v-model="searchForm.productType" style="width: 180px" placeholder="请选择产品类型" filterable>
  16. <el-option v-for="item in PRODUCT_TYPE" :key="item.value" :label="item.label" :value="item.value" />
  17. </el-select> -->
  18. <el-input maxlength="60" v-trim clearable v-model="searchForm.contractNumber" style="width: 200px;"
  19. placeholder="请输入合同号" />
  20. <div class="as-gravity-center-start">
  21. <div class="date-label">日期:</div>
  22. <el-date-picker unlink-panels v-model="value1" type="datetimerange" range-separator="到"
  23. start-placeholder="统计开始日期" end-placeholder="统计结束日期" style="margin: 0 10px 10px 10px"
  24. format="YYYY-MM-DD HH:mm:ss" :clearable="false" @change="dateChangeHandle" />
  25. </div>
  26. </template>
  27. </crud-template>
  28. </div>
  29. </template>
  30. <!-- 选装模式成本统计 -->
  31. <script lang="ts" setup>
  32. // @ts-ignore crudFrom模板
  33. import CrudTemplate from "@/crud/index.vue";
  34. import {
  35. ref,
  36. onMounted,
  37. computed
  38. } from "vue";
  39. import { ElMessage } from "element-plus";
  40. import BaseService from "@/utils/baseService";
  41. import moment from "moment";
  42. import $storeinitData from "@/store/initData"; //引入tab vuex
  43. import { exportFn, getDefaultTime, importFn, reportExportFn } from '@/views/settlement/exportFn'
  44. import { IsPermission } from '@/router/routerUtil'
  45. import { useRoute } from 'vue-router'
  46. const route = useRoute()
  47. const PRODUCT_TYPE = computed(() => {
  48. return $storeinitData.state.dictData['PRODUCT_TYPE'] || []
  49. })
  50. const crudRef = ref();
  51. const searchForm = ref({
  52. promotionChannels: "",
  53. productType: "",
  54. contractNumber: "",
  55. startTime: "",
  56. endTime: "",
  57. type: 1, // 1查询 2导出
  58. });
  59. const tableData = ref([]);
  60. //表单数据配置
  61. const formLabelWidth = "180px";
  62. const field = ref({
  63. tabSize: "small", //Table 的尺寸 large / default /small (默认default)
  64. searchShow: true, //是否显示搜索模块(默认false)
  65. border: true, //是否添加边框(默认false)
  66. dialogCustom: true, //自定义Dialog (默认false)
  67. dialogFooter: true, //隐藏弹窗页脚显示 (默认false)
  68. dialogWidth: "40%", //dialog宽度 (默认40%)
  69. crudShow: true, //是否显示CURD操作栏 (默认true)
  70. crudChildShow: true, //是否显示CURD子操作栏 (默认true)
  71. paginStart: true, //是否显示分页查询 (默认false)
  72. isPageSizes: true,
  73. pageLayout: 'total, sizes, prev, pager, next',
  74. titleDialog: "", //table 标题
  75. paging: {
  76. pageSize: 10,
  77. currentPage: 1,
  78. total: 0,
  79. costPriceAll: 0,
  80. costAmountAll: 0,
  81. },
  82. crud: {
  83. add: false,
  84. cudText: [
  85. {
  86. label: '成本单价总金额:',
  87. key: 'costPriceAll',
  88. isAmount: true,
  89. },
  90. {
  91. label: '成本总金额:',
  92. key: 'costAmountAll',
  93. isAmount: true,
  94. }
  95. ],
  96. },
  97. searchOperation: {
  98. isInitiateApproval: IsPermission(route, 'INITIATE_APPROVAL'), //发起审批
  99. initiateApprovalData: {
  100. key: 'optional_mode',
  101. processName: '选装模式成本统计',
  102. reqFileName: 'SETTLE_OPTIONAL_OPTIONALMODECOSTIMPORT'
  103. },
  104. isDownload: IsPermission(route, 'DERIVE_BASE'), // 导出
  105. isToLead: IsPermission(route, 'BATCH_LEAD'), // 导入
  106. isAdd: false,
  107. isTransferMachine: false,
  108. isTemplate: IsPermission(route, 'BATCH_LEAD'),
  109. templateUrl: import.meta.env.VITE_APP_UPLOAD_URL + 'sett-minio/template/收支管理/支出管理/选装模式成本统计(支出类).xlsx',
  110. templateFileName: '选装模式成本统计导入模板'
  111. },
  112. tableSize: -1,
  113. operateShow: true, //是否为表格添加操作栏(默认true)
  114. operateTitle: "操作", //操作栏标题(默认为"")
  115. operateFixed: false, //操作栏是否固定(默认false)
  116. operateWidth: "100", //操作栏宽度
  117. operate: {
  118. info: IsPermission(route, 'INFO_LIST'), //详情
  119. edit: false, //是否编辑(默认true)
  120. delete: false, //是否删除(默认true)
  121. remark: false, // 查看
  122. },
  123. extend: [
  124. {
  125. type: "index",
  126. label: "序号",
  127. },
  128. ],
  129. field: [
  130. {
  131. label: "推广渠道",
  132. prop: "promotionChannels",
  133. form: {
  134. formLabelWidth: formLabelWidth,
  135. width: "45%",
  136. type: "input",
  137. },
  138. },
  139. {
  140. label: "产品类型",
  141. prop: "productType",
  142. // listData: PRODUCT_TYPE,
  143. form: {
  144. formLabelWidth: formLabelWidth,
  145. width: "45%",
  146. type: "input",
  147. // listData: PRODUCT_TYPE,
  148. },
  149. },
  150. {
  151. label: "合同号",
  152. prop: "contractNumber",
  153. form: {
  154. formLabelWidth: formLabelWidth,
  155. width: "45%",
  156. type: "input",
  157. },
  158. },
  159. {
  160. label: "成本单价(元)",
  161. prop: "costPrice",
  162. isAmount: true,
  163. form: {
  164. formLabelWidth: formLabelWidth,
  165. width: "45%",
  166. type: "input",
  167. },
  168. },
  169. {
  170. label: "数量",
  171. prop: "quantity",
  172. form: {
  173. formLabelWidth: formLabelWidth,
  174. width: "45%",
  175. type: "input",
  176. },
  177. },
  178. {
  179. label: "成本金额(元)",
  180. prop: "costAmount",
  181. isAmount: true,
  182. form: {
  183. formLabelWidth: formLabelWidth,
  184. width: "45%",
  185. type: "input",
  186. },
  187. },
  188. {
  189. label: "日期",
  190. prop: "dateTime",
  191. funRuleStarts: true,
  192. funRule: (time: any) => {
  193. return time ? time.replace('T', ' ') : '-';
  194. },
  195. form: {
  196. funRuleStarts: true,
  197. funRule: (time: any) => {
  198. return time ? time.replace('T', ' ') : '-';
  199. },
  200. formLabelWidth: formLabelWidth,
  201. width: "45%",
  202. type: "input",
  203. },
  204. },
  205. {
  206. label: "备注",
  207. prop: "remark",
  208. form: {
  209. formLabelWidth: formLabelWidth,
  210. width: "45%",
  211. type: "input",
  212. },
  213. }
  214. ],
  215. });
  216. // 搜索按钮
  217. function btnSearch() {
  218. field.value.paging.currentPage = 1;
  219. getList();
  220. }
  221. // 搜索重置
  222. function refreshLeft() {
  223. field.value.paging.currentPage = 1;
  224. searchForm.value = {
  225. promotionChannels: "",
  226. productType: "",
  227. contractNumber: "",
  228. type: 1,
  229. startTime: "",
  230. endTime: "",
  231. };
  232. value1.value = defaultTime
  233. dateChangeHandle()
  234. tableData.value = [];
  235. getList();
  236. }
  237. const defaultTime: [Date, Date] = getDefaultTime('day', 1)
  238. const value1: any = ref(defaultTime) // 筛选时间
  239. // 时间
  240. function dateChangeHandle() {
  241. if (value1.value) {
  242. searchForm.value.startTime = value1.value[0]
  243. searchForm.value.endTime = value1.value[1]
  244. } else {
  245. searchForm.value.startTime = ''
  246. searchForm.value.endTime = ''
  247. }
  248. }
  249. function dateChange(time) {
  250. if (time) {
  251. time = moment(time).format("YYYY-MM-DDTHH:mm:ss");
  252. }
  253. return time
  254. }
  255. // 获取列表
  256. function getList() {
  257. if (!searchForm.value.startTime || !searchForm.value.endTime) {
  258. ElMessage.error('请选择查询开始时间和结束时间')
  259. return
  260. }
  261. searchForm.value.type = 1
  262. crudRef.value.tableLoding = true;
  263. // 参数
  264. const params: any = {
  265. pageNo: field.value.paging.currentPage,
  266. pageSize: field.value.paging.pageSize,
  267. };
  268. searchForm.value.startTime = dateChange(searchForm.value.startTime)
  269. searchForm.value.endTime = dateChange(searchForm.value.endTime)
  270. const searchFormList = { ...searchForm.value };
  271. for (const key in searchFormList) {
  272. if (searchFormList[key]) {
  273. params[key] = searchFormList[key];
  274. }
  275. }
  276. BaseService.postN('/settlew/optional/optionalmodecostfind', params).then((res: any) => {
  277. if (res && res.code === 0) {
  278. const bizContent = res.data
  279. const data = bizContent.data || [];
  280. tableData.value = data;
  281. crudRef.value.tableLoding = false;
  282. field.value.paging.total = bizContent.totalCount;
  283. field.value.paging.costPriceAll = bizContent.costPriceAll;
  284. field.value.paging.costAmountAll = bizContent.costAmountAll;
  285. } else {
  286. crudRef.value.tableLoding = false;
  287. ElMessage.error(res.message);
  288. }
  289. });
  290. }
  291. function handleCurrentChange(val: number) {
  292. field.value.paging.currentPage = val;
  293. getList();
  294. }
  295. // 生成报表
  296. function generateAeport() {
  297. downloadHandle(1)
  298. }
  299. // 导出
  300. const downloadHandle = (type) => {
  301. searchForm.value.type = 2
  302. searchForm.value.startTime = dateChange(searchForm.value.startTime)
  303. searchForm.value.endTime = dateChange(searchForm.value.endTime)
  304. if (type) {
  305. reportExportFn('/settlew/optional/optionalmodecostfind', searchForm.value, '选装模式成本统计').then((res) => {
  306. const initiateApprovalData = field.value.searchOperation.initiateApprovalData
  307. field.value.searchOperation.initiateApprovalData = { ...initiateApprovalData, ...res }
  308. }).finally(() => {
  309. console.log('error')
  310. })
  311. } else {
  312. // 普通导出
  313. exportFn('/settlew/optional/optionalmodecostfind', searchForm.value, '选装模式成本统计')
  314. }
  315. }
  316. // 导入
  317. function importData(url, reportFileName) {
  318. importFn('/settlew/optional/optionalmodecostimport', () => { }, { excelUrl: url, reportFileName })
  319. }
  320. onMounted(() => {
  321. dateChangeHandle()
  322. getList();
  323. })
  324. </script>