index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="项目名称" prop="projectName">
  5. <el-input
  6. v-model="queryParams.projectName"
  7. placeholder="请输入项目名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="接入标志" prop="connectFlag">
  13. <el-input
  14. v-model="queryParams.connectFlag"
  15. placeholder="请输入接入标志"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. icon="el-icon-plus"
  30. size="mini"
  31. @click="handleAdd"
  32. v-hasPermi="['zcustom:project:add']"
  33. >新增</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button
  37. type="danger"
  38. icon="el-icon-delete"
  39. size="mini"
  40. :disabled="multiple"
  41. @click="handleDelete"
  42. v-hasPermi="['zcustom:project:remove']"
  43. >删除</el-button>
  44. </el-col>
  45. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  46. </el-row>
  47. <el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
  48. <el-table-column type="selection" width="55" align="center" />
  49. <el-table-column label="序号" width="50">
  50. <template slot-scope="scope">
  51. {{(scope.$index + 1) + ((queryParams.pageNum - 1) * queryParams.pageSize)}}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="项目名称" align="center" prop="projectName" />
  55. <el-table-column label="项目分类" align="center">
  56. <template slot-scope="scope">
  57. <span v-if="scope.row.subdivision <= 10">{{ typeListA[scope.row.subdivision - 1].name }}</span>
  58. <span v-if="scope.row.subdivision > 10">{{ typeListB[scope.row.subdivision - 1].name }}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="创建时间" align="center">
  62. <template slot-scope="scope">
  63. {{ scope.row.createTime }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  67. <template slot-scope="scope">
  68. <el-button
  69. size="mini"
  70. type="text"
  71. icon="el-icon-edit"
  72. @click="handleUpdate(scope.row)"
  73. v-hasPermi="['zcustom:project:edit']"
  74. >修改</el-button>
  75. <el-button
  76. size="mini"
  77. type="text"
  78. icon="el-icon-delete"
  79. @click="handleDelete(scope.row)"
  80. v-hasPermi="['zcustom:project:remove']"
  81. >删除</el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. <pagination
  86. v-show="total>0"
  87. :total="total"
  88. :page.sync="queryParams.pageNum"
  89. :limit.sync="queryParams.pageSize"
  90. @pagination="getList"
  91. />
  92. <!-- 添加或修改工程项目对话框 -->
  93. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="800px" append-to-body>
  94. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  95. <el-form-item label="项目名称" prop="projectName">
  96. <el-input v-model="form.projectName" placeholder="请输入项目名称" />
  97. </el-form-item>
  98. <el-form-item label="所属单位" prop="unitCode">
  99. <el-cascader :options="treeList" placeholder="请选择所属单位" v-model="form.appOrg" :props="props" style="width: 400px">
  100. <template slot-scope="{ node, data }">
  101. <span>{{ data.appName }}</span>
  102. </template>
  103. </el-cascader>
  104. </el-form-item>
  105. <el-form-item label="项目类型" prop="type">
  106. <el-radio v-model="flag" label="1">在建</el-radio>
  107. <el-radio v-model="flag" label="2">施工</el-radio>
  108. </el-form-item>
  109. <el-form-item label="项目小类" prop="unitCode">
  110. <el-select v-model="form.subdivision" placeholder="请选择">
  111. <el-option
  112. v-if="flag === '1'"
  113. v-for="item in typeListA"
  114. :key="item.key"
  115. :label="item.name"
  116. :value="item.key"/>
  117. <el-option
  118. v-if="flag === '2'"
  119. v-for="item in typeListB"
  120. :key="item.key"
  121. :label="item.name"
  122. :value="item.key"/>
  123. </el-select>
  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 { listProject, getProject, delProject, addProject, updateProject } from "@/api/zcustom/project";
  135. import { getListTree, listPlatAppOrg } from '@/api/zcustom/platAppOrg'
  136. export default {
  137. name: "Project",
  138. data() {
  139. return {
  140. props:{
  141. value: 'appOrg',
  142. label: 'appName',
  143. checkStrictly: true,
  144. emitPath: false
  145. },
  146. treeList:[],
  147. typeListA:[
  148. {
  149. key: 1,
  150. name:'可研评审'
  151. },
  152. {
  153. key: 2,
  154. name:'初设评审'
  155. },
  156. {
  157. key: 3,
  158. name:'政府立项备案'
  159. },
  160. {
  161. key: 4,
  162. name:'土地手续'
  163. },
  164. {
  165. key: 5,
  166. name:'用地规划'
  167. },
  168. {
  169. key: 6,
  170. name:'工程规划'
  171. },
  172. {
  173. key: 7,
  174. name:'设计招标'
  175. },
  176. {
  177. key: 8,
  178. name:'施工招标'
  179. },
  180. {
  181. key: 9,
  182. name:'监理招标'
  183. },
  184. {
  185. key: 10,
  186. name:'施工许可'
  187. },
  188. ],
  189. typeListB:[
  190. {
  191. key: 11,
  192. name:'基础施工'
  193. },
  194. {
  195. key: 12,
  196. name:'主体工程'
  197. },
  198. {
  199. key: 13,
  200. name:'室内外装修'
  201. },
  202. {
  203. key: 14,
  204. name:'室外工程'
  205. }
  206. ],
  207. flag: '1',
  208. // 根路径
  209. baseURL: process.env.VUE_APP_BASE_API,
  210. // 遮罩层
  211. loading: true,
  212. // 选中数组
  213. ids: [],
  214. // 非单个禁用
  215. single: true,
  216. // 非多个禁用
  217. multiple: true,
  218. // 显示搜索条件
  219. showSearch: true,
  220. // 总条数
  221. total: 0,
  222. // 工程项目表格数据
  223. projectList: [],
  224. platAppOrgList: [],
  225. // 弹出层标题
  226. title: "",
  227. // 是否显示弹出层
  228. open: false,
  229. // 查询参数
  230. queryParams: {
  231. pageNum: 1,
  232. pageSize: 10,
  233. projectName: null,
  234. unitCode: null,
  235. connectFlag: null,
  236. },
  237. // 表单参数
  238. form: {},
  239. // 表单校验
  240. rules: {
  241. id: [
  242. { required: true, message: "项目id不能为空", trigger: "blur" }
  243. ],
  244. projectName: [
  245. { required: true, message: "项目名称不能为空", trigger: "blur" }
  246. ],
  247. appOrg: [
  248. { required: true, message: "所属单位id不能为空", trigger: "blur" }
  249. ],
  250. connectFlag: [
  251. { required: true, message: "接入标志不能为空", trigger: "blur" }
  252. ],
  253. delFlag: [
  254. { required: true, message: "删除标志不能为空", trigger: "blur" }
  255. ],
  256. }
  257. };
  258. },
  259. created() {
  260. this.getList();
  261. this.getUnitList()
  262. this.getListTree();
  263. },
  264. methods: {
  265. /** 查询工程项目列表 */
  266. getList() {
  267. this.loading = true;
  268. listProject(this.queryParams).then(response => {
  269. this.projectList = response.data.records;
  270. this.total = response.data.total;
  271. this.loading = false;
  272. });
  273. },
  274. getListTree(){
  275. getListTree().then(res => {
  276. this.treeList.push(res.data)
  277. })
  278. },
  279. getUnitList() {
  280. listPlatAppOrg().then(response => {
  281. this.platAppOrgList = response.data.records;
  282. });
  283. },
  284. // 取消按钮
  285. cancel() {
  286. this.open = false;
  287. this.reset();
  288. },
  289. // 表单重置
  290. reset() {
  291. this.form = {
  292. id: null,
  293. projectName: null,
  294. unitCode: null,
  295. connectFlag: null,
  296. delFlag: null,
  297. };
  298. this.resetForm("form");
  299. },
  300. /** 搜索按钮操作 */
  301. handleQuery() {
  302. this.queryParams.pageNum = 1;
  303. this.getList();
  304. },
  305. /** 重置按钮操作 */
  306. resetQuery() {
  307. this.resetForm("queryForm");
  308. this.handleQuery();
  309. },
  310. // 多选框选中数据
  311. handleSelectionChange(selection) {
  312. this.ids = selection.map(item => item.id)
  313. this.single = selection.length!==1
  314. this.multiple = !selection.length
  315. },
  316. /** 新增按钮操作 */
  317. handleAdd() {
  318. this.reset();
  319. this.open = true;
  320. this.title = "添加工程项目";
  321. },
  322. /** 修改按钮操作 */
  323. handleUpdate(row) {
  324. this.reset();
  325. this.flag = Number(row.subdivision) < 10 ? '1' : '2'
  326. const id = row.id || this.ids
  327. getProject(id).then(response => {
  328. this.form = response.data;
  329. this.open = true;
  330. this.title = "修改工程项目";
  331. });
  332. },
  333. /** 提交按钮 */
  334. submitForm() {
  335. this.$refs["form"].validate(valid => {
  336. if (valid) {
  337. if (this.form.id != null) {
  338. updateProject(this.form).then(response => {
  339. this.$modal.msgSuccess("修改成功");
  340. this.open = false;
  341. this.getList();
  342. });
  343. } else {
  344. addProject(this.form).then(response => {
  345. this.$modal.msgSuccess("新增成功");
  346. this.open = false;
  347. this.getList();
  348. });
  349. }
  350. }
  351. });
  352. },
  353. /** 删除按钮操作 */
  354. handleDelete(row) {
  355. const ids = row.id || this.ids;
  356. this.$modal.confirm('是否确认删除?').then(function() {
  357. return delProject(ids);
  358. }).then(() => {
  359. this.getList();
  360. this.$modal.msgSuccess("删除成功");
  361. }).catch(() => {});
  362. },
  363. }
  364. };
  365. </script>