index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. wholeTree
  12. ></org-tree>
  13. </el-col>
  14. <!--用户数据-->
  15. <el-col :span="20" :xs="24">
  16. <div class="main-right-box">
  17. <!-- 搜索条件 -->
  18. <div class="main-search-box">
  19. <el-form
  20. :model="queryParams"
  21. ref="queryForm"
  22. size="small"
  23. :inline="true"
  24. v-show="showSearch"
  25. label-width="120px"
  26. >
  27. <el-form-item label="所属年份" prop="year">
  28. <el-date-picker
  29. v-model="queryParams.year"
  30. :clearable="timeClearable"
  31. type="year"
  32. placeholder="选择时间"
  33. value-format="yyyy"
  34. @change="handleQuery"
  35. >
  36. </el-date-picker>
  37. </el-form-item>
  38. </el-form>
  39. <el-row :gutter="10" class="mb8">
  40. <el-col :span="1.5">
  41. <el-button
  42. type="primary"
  43. icon="el-icon-plus"
  44. size="mini"
  45. @click="handleAdd(null)"
  46. v-hasPermi="['core:book:add']"
  47. >新增
  48. </el-button>
  49. </el-col>
  50. <right-toolbar
  51. :showSearch.sync="showSearch"
  52. @queryTable="getList"
  53. ></right-toolbar>
  54. </el-row>
  55. </div>
  56. <!-- 表格数据 -->
  57. <el-table
  58. border
  59. height="700"
  60. size="small"
  61. v-loading="loading"
  62. :data="dataList"
  63. >
  64. <el-table-column
  65. label="序号"
  66. type="index"
  67. align="center"
  68. width="60"
  69. />
  70. <el-table-column
  71. label="签署机构"
  72. align="left"
  73. width="200"
  74. prop="orgName"
  75. />
  76. <el-table-column
  77. label="签署类型"
  78. align="left"
  79. width="160"
  80. prop="type"
  81. >
  82. <template slot-scope="r"
  83. >{{
  84. getLabel(dict.type.safety_book_type, `${r.row.type}`)
  85. }}
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. label="责任书所属年份"
  90. align="center"
  91. width="140"
  92. prop="year"
  93. />
  94. <el-table-column label="签署人" align="center" prop="userName">
  95. </el-table-column>
  96. <el-table-column label="签署时间" align="center" prop="createTime" />
  97. <el-table-column
  98. label="操作"
  99. width="180"
  100. fixed="right"
  101. align="center"
  102. class-name="small-padding fixed-width"
  103. >
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit-outline"
  109. @click="handleAdd(scope.row.id)"
  110. v-hasPermi="['core:book:add']"
  111. >编辑
  112. </el-button>
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-info"
  117. @click="handleInfo(scope.row)"
  118. v-hasPermi="['core:book:query']"
  119. v-if="false"
  120. >详情
  121. </el-button>
  122. <el-button
  123. size="mini"
  124. type="text"
  125. icon="el-icon-delete"
  126. @click="handleDelete(scope.row)"
  127. v-hasPermi="['core:book:remove']"
  128. >删除
  129. </el-button>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <pagination
  134. v-show="total > 0"
  135. :total="total"
  136. :page.sync="queryParams.pageNum"
  137. :limit.sync="queryParams.pageSize"
  138. @pagination="getList"
  139. />
  140. </div>
  141. </el-col>
  142. </el-row>
  143. <dialog-edit ref="editDialog" @success="getList()"></dialog-edit>
  144. </div>
  145. </template>
  146. <script>
  147. import {
  148. listSafetyBook,
  149. getSafetyBook,
  150. editOrAdd,
  151. delSafetyBook,
  152. } from "@/api/safetyBook/index";
  153. import { getLabel } from "@/views/commonOption";
  154. import DialogEdit from "./dialog.edit";
  155. import { deptTreeSelect } from "@/api/system/public";
  156. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  157. import OrgTree from "@/components/orgTree/index.vue";
  158. import kOrgTree from "@/components/k-orgTree/index.vue";
  159. import KFileUpload from "@/components/K-FileUpload/index.vue";
  160. import tableList from "@/mixins/tableList";
  161. export default {
  162. dicts: [
  163. "safety_book_type"
  164. ],
  165. name: "safetyBook",
  166. components: { OrgTree, kOrgTree, KFileUpload, DialogEdit },
  167. mixins: [tableList],
  168. data() {
  169. return {
  170. // 遮罩层
  171. loading: true,
  172. // 选中数组
  173. ids: [],
  174. // 非单个禁用
  175. single: true,
  176. // 非多个禁用
  177. multiple: true,
  178. // 显示搜索条件
  179. showSearch: true,
  180. // 总条数
  181. total: 0,
  182. // 安全责任书表格数据
  183. dataList: [],
  184. // 弹出层标题
  185. title: "",
  186. // 是否显示弹出层
  187. open: false,
  188. // 机构树选项
  189. deptOptions: undefined,
  190. // 机构名称
  191. deptName: undefined,
  192. //是否关联下级
  193. checked: false,
  194. timeClearable: true,
  195. defaultProps: {
  196. children: "children",
  197. label: "name",
  198. },
  199. formFileListDefualtValue: [],
  200. // 查询参数
  201. queryParams: {
  202. checkSub: true,
  203. pageNum: 1,
  204. pageSize: 10,
  205. orgId: null,
  206. year: null,
  207. searchOrgId: null,
  208. },
  209. // 表单参数
  210. form: {},
  211. //默认选中节点
  212. defaultKeys: [],
  213. };
  214. },
  215. watch: {
  216. // 根据名称筛选机构树
  217. deptName(val) {
  218. this.$refs.tree.filter(val);
  219. },
  220. },
  221. created() {
  222. this.getDeptTree();
  223. this.getConfigKey("sys.user.initPassword").then((response) => {
  224. this.initPassword = response.msg;
  225. });
  226. this.getList();
  227. },
  228. methods: {
  229. getLabel(options, value) {
  230. return getLabel(options, value);
  231. },
  232. //新增
  233. handleAdd(id) {
  234. this.$refs.editDialog.show(id);
  235. },
  236. /** 查询安全责任书列表 */
  237. getList() {
  238. this.loading = true;
  239. listSafetyBook(this.queryParams).then((response) => {
  240. this.dataList = response.rows;
  241. this.total = response.total;
  242. this.loading = false;
  243. });
  244. },
  245. getDeptTree() {
  246. deptTreeSelect().then((response) => {
  247. this.deptOptions = response.data;
  248. });
  249. },
  250. // 节点单击事件
  251. clickTreeNode(data) {
  252. this.queryParams.orgId = data.id;
  253. this.handleQuery();
  254. },
  255. /** 下穿状态改变*/
  256. changeCheckBox() {
  257. this.getList();
  258. },
  259. getDefaultKey(key) {
  260. this.queryParams.orgId = key;
  261. this.getList();
  262. },
  263. //单选框状态改变
  264. checkChange(state) {
  265. this.queryParams.checkSub = state;
  266. this.handleQuery();
  267. },
  268. // 筛选节点
  269. filterNode(value, data) {
  270. if (!value) return true;
  271. return data.name.indexOf(value) !== -1;
  272. },
  273. // 节点单击事件
  274. handleNodeClick(data) {
  275. this.queryParams.orgId = data.id;
  276. this.handleQuery();
  277. },
  278. /** 搜索按钮操作 */
  279. handleQuery() {
  280. this.queryParams.pageNum = 1;
  281. this.getList();
  282. },
  283. /** 删除按钮操作 */
  284. handleDelete(row) {
  285. const ids = row.id || this.ids;
  286. this.$modal
  287. .confirm("是否确认删除?")
  288. .then(function () {
  289. return delSafetyBook(ids);
  290. })
  291. .then(() => {
  292. this.getList();
  293. this.$modal.msgSuccess("删除成功");
  294. })
  295. .catch(() => {});
  296. },
  297. /** 详情按钮操作 */
  298. handleInfo(row) {
  299. this.reset();
  300. const id = row.id || this.ids;
  301. getSafetyBook(id).then((response) => {
  302. this.form = response.data;
  303. this.open = true;
  304. this.title = "安全责任书详情";
  305. });
  306. },
  307. },
  308. };
  309. </script>
  310. <style>
  311. .ellipsis {
  312. white-space: nowrap;
  313. overflow: hidden;
  314. text-overflow: ellipsis;
  315. }
  316. </style>