consume.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="所属档期" prop="scheduleId">
  5. <el-select style="width:205.4px" v-model="queryParams.scheduleId" placeholder="请选择档期" clearable size="small" >
  6. <el-option
  7. v-for="item in scheduleList"
  8. :key="item.id"
  9. :label="item.name"
  10. :value="item.id"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="创建时间" prop="createTime">
  15. <el-date-picker
  16. style="width:225.4px"
  17. clearable size="small"
  18. v-model="dateRange"
  19. type="daterange"
  20. value-format="yyyy-MM-dd"
  21. start-placeholder="开始日期"
  22. end-placeholder="结束日期">
  23. </el-date-picker>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button
  33. type="primary"
  34. icon="el-icon-plus"
  35. size="mini"
  36. @click="handleAdd"
  37. v-hasPermi="['system:consume:add']"
  38. >新增</el-button>
  39. </el-col>
  40. <el-col :span="1.5">
  41. <el-button
  42. type="success"
  43. icon="el-icon-edit"
  44. size="mini"
  45. :disabled="single"
  46. @click="handleUpdate"
  47. v-hasPermi="['system:consume:edit']"
  48. >修改</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="danger"
  53. icon="el-icon-delete"
  54. size="mini"
  55. :disabled="multiple"
  56. @click="handleDelete"
  57. v-hasPermi="['system:consume:remove']"
  58. >删除</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="warning"
  63. icon="el-icon-download"
  64. size="mini"
  65. @click="handleExport"
  66. v-hasPermi="['system:consume:export']"
  67. >导出</el-button>
  68. </el-col>
  69. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  70. </el-row>
  71. <el-table v-loading="loading" :data="consumeList" @selection-change="handleSelectionChange">
  72. <el-table-column type="selection" width="55" align="center" />
  73. <el-table-column label="id" align="center" prop="id" />
  74. <el-table-column label="档期" align="center" prop="scheduleName" />
  75. <el-table-column label="消费金额" align="center" prop="money" />
  76. <el-table-column label="创建时间" align="center" prop="createTime" />
  77. <!-- <el-table-column label="创建人ID" align="center" prop="createUserId" />
  78. <el-table-column label="修改人ID" align="center" prop="updateUserId" /> -->
  79. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  80. <template slot-scope="scope">
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-edit"
  85. @click="handleUpdate(scope.row)"
  86. v-hasPermi="['company:consume:edit']"
  87. >修改</el-button>
  88. <el-button
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['company:consume:remove']"
  94. >删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改公司档期消费对话框 -->
  106. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item label="所属档期" prop="scheduleId">
  109. <el-select style="width: 350px" v-model="form.scheduleId" placeholder="请选择档期" clearable size="small" >
  110. <el-option
  111. v-for="item in scheduleList"
  112. :key="item.id"
  113. :label="item.name"
  114. :value="item.id"
  115. />
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item label="消费金额" label-width="80px" prop="money">
  119. <el-input style="width: 350px" v-model="form.money" pattern="\d+(\.\d{1,2})?" type="number" placeholder="请输入消费金额" />
  120. <!-- <el-input-number style="width: 350px" onkeyup="value=(value.replace(/\D/g,'')==''?'':parseInt(value))" v-model="form.money" :step="10" :precision="2" :min="0.00" placeholder="请输入消费金额" />
  121. -->
  122. </el-form-item>
  123. </el-form>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button type="primary" @click="submitForm">确 定</el-button>
  126. <el-button @click="cancel">取 消</el-button>
  127. </div>
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. import { listSchedule } from "@/api/company/tcmScheduleReport";
  133. import { listConsume, getConsume, delConsume, addConsume, updateConsume, exportConsume } from "@/api/company/tcmconsume";
  134. export default {
  135. name: "Consume",
  136. data() {
  137. return {
  138. // 遮罩层
  139. loading: true,
  140. // 选中数组
  141. ids: [],
  142. // 非单个禁用
  143. single: true,
  144. // 非多个禁用
  145. multiple: true,
  146. // 显示搜索条件
  147. showSearch: true,
  148. // 总条数
  149. total: 0,
  150. // 公司档期消费表格数据
  151. consumeList: [],
  152. dateRange: [],
  153. // 弹出层标题
  154. title: "",
  155. // 是否显示弹出层
  156. open: false,
  157. // 查询参数
  158. queryParams: {
  159. pageNum: 1,
  160. pageSize: 10,
  161. },
  162. scheduleList:[],
  163. // 表单参数
  164. form: {},
  165. // 表单校验
  166. rules: {
  167. scheduleId: [
  168. { required: true, message: "请选择档期", trigger: "blur" }
  169. ],
  170. money: [
  171. { required: true, message: "消费金额为空", trigger: "blur" }
  172. ],
  173. }
  174. };
  175. },
  176. created() {
  177. this.getList();
  178. this.getListSchedule();
  179. },
  180. methods: {
  181. /** 查询公司档期消费列表 */
  182. getList() {
  183. this.loading = true;
  184. listConsume(this.addDateRange(this.queryParams,this.dateRange)).then(response => {
  185. this.consumeList = response.rows;
  186. this.total = response.total;
  187. this.loading = false;
  188. });
  189. },
  190. getListSchedule() {
  191. this.loading = true;
  192. listSchedule().then(response => {
  193. this.scheduleList = response.rows;
  194. });
  195. },
  196. // 取消按钮
  197. cancel() {
  198. this.open = false;
  199. this.reset();
  200. },
  201. // 表单重置
  202. reset() {
  203. this.form = {
  204. id: null,
  205. scheduleId: null,
  206. companyId: null,
  207. money: null,
  208. createUserId: null,
  209. updateUserId: null,
  210. createTime: null,
  211. updateTime: null
  212. };
  213. this.resetForm("form");
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.queryParams.pageNum = 1;
  218. this.getList();
  219. },
  220. /** 重置按钮操作 */
  221. resetQuery() {
  222. this.resetForm("queryForm");
  223. this.handleQuery();
  224. },
  225. // 多选框选中数据
  226. handleSelectionChange(selection) {
  227. this.ids = selection.map(item => item.id)
  228. this.single = selection.length!==1
  229. this.multiple = !selection.length
  230. },
  231. /** 新增按钮操作 */
  232. handleAdd() {
  233. this.reset();
  234. this.open = true;
  235. this.title = "添加档期消费";
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.reset();
  240. const id = row.id || this.ids
  241. getConsume(id).then(response => {
  242. this.form = response.data;
  243. this.open = true;
  244. this.title = "修改档期消费";
  245. });
  246. },
  247. /** 提交按钮 */
  248. submitForm() {
  249. this.$refs["form"].validate(valid => {
  250. if (valid) {
  251. if (this.form.id != null) {
  252. updateConsume(this.form).then(response => {
  253. if (response.code === 200) {
  254. this.msgSuccess("修改成功");
  255. this.open = false;
  256. this.getList();
  257. }
  258. });
  259. } else {
  260. addConsume(this.form).then(response => {
  261. if (response.code === 200) {
  262. this.msgSuccess("新增成功");
  263. this.open = false;
  264. this.getList();
  265. }
  266. });
  267. }
  268. }
  269. });
  270. },
  271. /** 删除按钮操作 */
  272. handleDelete(row) {
  273. const ids = row.id || this.ids;
  274. this.$confirm('是否确认删除公司档期消费编号为"' + ids + '"的数据项?', "警告", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning"
  278. }).then(function() {
  279. return delConsume(ids);
  280. }).then(() => {
  281. this.getList();
  282. this.msgSuccess("删除成功");
  283. }).catch(function() {});
  284. },
  285. /** 导出按钮操作 */
  286. handleExport() {
  287. const queryParams = this.queryParams;
  288. this.$confirm('是否确认导出所有公司档期消费数据项?', "警告", {
  289. confirmButtonText: "确定",
  290. cancelButtonText: "取消",
  291. type: "warning"
  292. }).then(function() {
  293. return exportConsume(queryParams);
  294. }).then(response => {
  295. this.download(response.msg);
  296. }).catch(function() {});
  297. }
  298. }
  299. };
  300. </script>