index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" l @submit.native.prevent>
  4. <el-form-item label="日报时间" prop="dailyTime">
  5. <el-date-picker clearable v-model="queryParams.dailyTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择日报时间"></el-date-picker>
  6. </el-form-item>
  7. <el-form-item label="日报标题" prop="dailyTitle">
  8. <el-input v-model="queryParams.dailyTitle" placeholder="请输入日报标题" clearable @keyup.enter.native="handleQuery" />
  9. </el-form-item>
  10. <el-form-item prop="deptId">
  11. <template slot="label">
  12. <span @click="changeQueryType" v-if="queryParams.deptName === 0">本级及下级</span>
  13. <span @click="changeQueryType" v-if="queryParams.deptName === 1">只查询本级</span>
  14. </template>
  15. <treeselect v-model="queryParams.deptId" :options="deptOptions" multiple:false :show-count="true"
  16. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'" style="width: 240px"/>
  17. </el-form-item>
  18. <!--<el-form-item label="部门名称" prop="deptName">
  19. <el-input
  20. v-model="queryParams.deptName"
  21. placeholder="请输入部门名称"
  22. clearable
  23. @keyup.enter.native="handleQuery"
  24. />
  25. </el-form-item>-->
  26. <el-form-item>
  27. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  28. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button
  34. type="primary"
  35. plain
  36. icon="el-icon-plus"
  37. size="mini"
  38. @click="handleAdd"
  39. v-hasPermi="['system:daily:add']"
  40. >新增</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="success"
  45. plain
  46. icon="el-icon-edit"
  47. size="mini"
  48. :disabled="single"
  49. @click="handleUpdate"
  50. v-hasPermi="['system:daily:edit']"
  51. >修改</el-button>
  52. </el-col>
  53. <el-col :span="1.5">
  54. <el-button
  55. type="danger"
  56. plain
  57. icon="el-icon-delete"
  58. size="mini"
  59. :disabled="multiple"
  60. @click="handleDelete"
  61. v-hasPermi="['system:daily:remove']"
  62. >删除</el-button>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-button
  66. type="warning"
  67. plain
  68. icon="el-icon-download"
  69. size="mini"
  70. @click="handleExport"
  71. v-hasPermi="['system:daily:export']"
  72. >导出</el-button>
  73. </el-col>
  74. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  75. </el-row>
  76. <el-table v-loading="loading" :data="dailyList" @selection-change="handleSelectionChange">
  77. <el-table-column type="selection" width="55" align="center" />
  78. <!--<el-table-column label="日报类型(字典)" align="center" prop="dailyType" />-->
  79. <el-table-column label="日报时间" align="center" prop="dailyTime" width="180">
  80. <template slot-scope="scope">
  81. <span>{{ parseTime(scope.row.dailyTime, '{y}-{m}-{d}') }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="日报标题" align="center" prop="dailyTitle" />
  85. <el-table-column label="日报内容" align="center" prop="dailyContent" />
  86. <el-table-column label="所属部门" align="center" prop="deptName" />
  87. <el-table-column label="创建人" align="center" prop="createName" />
  88. <el-table-column label="审计状态" align="center" prop="status" >
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.status === '0' ? "未审计":"已审计"}}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  94. <template slot-scope="scope">
  95. <el-button
  96. size="mini"
  97. type="text"
  98. icon="el-icon-edit"
  99. @click="handleUpdate(scope.row)"
  100. v-hasPermi="['system:daily:edit']"
  101. >修改</el-button>
  102. <el-button
  103. size="mini"
  104. type="text"
  105. icon="el-icon-delete"
  106. @click="handleDelete(scope.row)"
  107. v-hasPermi="['system:daily:remove']"
  108. >删除</el-button>
  109. </template>
  110. </el-table-column>
  111. </el-table>
  112. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  113. <!-- 添加或修改日报对话框 -->
  114. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  115. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  116. <el-form-item label="日报时间" prop="dailyTime">
  117. <el-date-picker clearable v-model="form.dailyTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择日报时间"></el-date-picker>
  118. </el-form-item>
  119. <el-form-item label="日报标题" prop="dailyTitle"><el-input v-model="form.dailyTitle" placeholder="请输入日报标题" maxlength="50" /></el-form-item>
  120. <el-form-item label="日报内容"><editor v-model="form.dailyContent" :min-height="192" maxlength="2000" /></el-form-item>
  121. <el-form-item label="所属部门" prop="deptName">
  122. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true"
  123. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'" style="width: 240px"/>
  124. </el-form-item>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button type="primary" @click="submitForm">确 定</el-button>
  128. <el-button @click="cancel">取 消</el-button>
  129. </div>
  130. </el-dialog>
  131. </div>
  132. </template>
  133. <script>
  134. import { listDaily, getDaily, delDaily, addDaily, updateDaily } from '@/api/data/daily/daily';
  135. import {treeselect} from "@/api/system/dept";
  136. import Treeselect from "@riophae/vue-treeselect";
  137. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  138. import deptselector from '@/views/components/deptselector.vue'
  139. import fileUpload from '@/views/components/FileUpload/index.vue'
  140. export default {
  141. components:{
  142. Treeselect,
  143. deptselector,
  144. fileUpload
  145. },
  146. name: 'Daily',
  147. data() {
  148. return {
  149. // 遮罩层
  150. loading: true,
  151. // 选中数组
  152. ids: [],
  153. // 非单个禁用
  154. single: true,
  155. // 非多个禁用
  156. multiple: true,
  157. // 显示搜索条件
  158. showSearch: true,
  159. // 总条数
  160. total: 0,
  161. // 日报表格数据
  162. dailyList: [],
  163. // 弹出层标题
  164. title: '',
  165. // 是否显示弹出层
  166. open: false,
  167. // 部门树选项
  168. deptOptions: [],
  169. // 查询参数
  170. queryParams: {
  171. pageNum: 1,
  172. pageSize: 10,
  173. dataStatus: null,
  174. dataDeptId: null,
  175. dailyType: null,
  176. dailyTime: null,
  177. dailyTitle: null,
  178. dailyContent: null,
  179. deptId: null,
  180. deptName: 0,
  181. createName:null
  182. },
  183. // 表单参数
  184. form: {},
  185. // 表单校验
  186. rules: {}
  187. };
  188. },
  189. created() {
  190. this.getList();
  191. this.getTreeselect();
  192. },
  193. methods: {
  194. hx(node) {
  195. this.form.deptId = node.id
  196. this.form.deptName = node.label
  197. },
  198. /** 查询部门下拉树结构 */
  199. getTreeselect() {
  200. treeselect().then(response => {
  201. this.deptOptions = response.data;
  202. });
  203. },
  204. /** 查询日报列表 */
  205. getList() {
  206. this.loading = true;
  207. listDaily(this.queryParams).then(response => {
  208. this.dailyList = response.rows;
  209. this.total = response.total;
  210. this.loading = false;
  211. });
  212. },
  213. // 取消按钮
  214. cancel() {
  215. this.open = false;
  216. this.reset();
  217. },
  218. // 表单重置
  219. reset() {
  220. this.form = {
  221. id: null,
  222. createBy: null,
  223. createTime: null,
  224. updateBy: null,
  225. updateTime: null,
  226. dataStatus: '0',
  227. dataDeptId: null,
  228. dailyType: null,
  229. dailyTime: null,
  230. dailyTitle: null,
  231. dailyContent: null,
  232. deptId: null,
  233. deptName: null
  234. };
  235. this.resetForm('form');
  236. },
  237. /** 搜索按钮操作 */
  238. handleQuery() {
  239. this.queryParams.pageNum = 1;
  240. this.getList();
  241. },
  242. /** 重置按钮操作 */
  243. resetQuery() {
  244. this.queryParams.deptName = 0;
  245. this.resetForm('queryForm');
  246. this.handleQuery();
  247. },
  248. // 多选框选中数据
  249. handleSelectionChange(selection) {
  250. this.ids = selection.map(item => item.id);
  251. this.single = selection.length !== 1;
  252. this.multiple = !selection.length;
  253. },
  254. /** 新增按钮操作 */
  255. handleAdd() {
  256. this.reset();
  257. this.open = true;
  258. this.title = '添加日报';
  259. },
  260. /** 修改按钮操作 */
  261. handleUpdate(row) {
  262. this.reset();
  263. const id = row.id || this.ids;
  264. getDaily(id).then(response => {
  265. this.form = response.data;
  266. this.open = true;
  267. this.title = '修改日报';
  268. });
  269. },
  270. /** 提交按钮 */
  271. submitForm() {
  272. this.$refs['form'].validate(valid => {
  273. if (valid) {
  274. if (this.form.id != null) {
  275. updateDaily(this.form).then(response => {
  276. this.$modal.msgSuccess('修改成功');
  277. this.open = false;
  278. this.getList();
  279. });
  280. } else {
  281. addDaily(this.form).then(response => {
  282. this.$modal.msgSuccess('新增成功');
  283. this.open = false;
  284. this.getList();
  285. });
  286. }
  287. }
  288. });
  289. },
  290. /** 删除按钮操作 */
  291. handleDelete(row) {
  292. const ids = row.id || this.ids;
  293. this.$modal
  294. .confirm('是否确认删除数据项?')
  295. .then(function() {
  296. return delDaily(ids);
  297. })
  298. .then(() => {
  299. this.getList();
  300. this.$modal.msgSuccess('删除成功');
  301. })
  302. .catch(() => {});
  303. },
  304. /** 导出按钮操作 */
  305. handleExport() {
  306. this.download(
  307. 'system/daily/export',
  308. {
  309. ...this.queryParams
  310. },
  311. `daily_${new Date().getTime()}.xlsx`
  312. );
  313. },
  314. // 点击按钮修改是否只查询本级部门用户
  315. changeQueryType() {
  316. this.queryParams.deptName = this.queryParams.deptName === 0 ? 1 : 0;
  317. }
  318. }
  319. };
  320. </script>