index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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[Number(scope.row.subdivision) - 1].name }}</span>
  58. <span v-if="scope.row.subdivision > 10">{{ typeListB[Number(scope.row.subdivision) - 10].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="100px">
  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="abscissa">
  99. <el-input v-model="form.abscissa" placeholder="请输入项目经度" />
  100. </el-form-item>
  101. <el-form-item label="项目纬度" prop="ordinate">
  102. <el-input v-model="form.ordinate" placeholder="请输入项目纬度" />
  103. </el-form-item>
  104. <el-form-item label="施工单位" prop="constructionUnit">
  105. <el-input v-model="form.constructionUnit" placeholder="请输入施工单位" />
  106. </el-form-item>
  107. <el-form-item label="监理单位" prop="ordinate">
  108. <el-input v-model="form.supervisionUnit" placeholder="请输入监理单位" />
  109. </el-form-item>
  110. <el-form-item label="所属单位" prop="appOrg">
  111. <el-cascader :options="treeList" placeholder="请选择所属单位" v-model="form.appOrg" :props="props" style="width: 400px">
  112. <template slot-scope="{ node, data }">
  113. <span>{{ data.appName }}</span>
  114. </template>
  115. </el-cascader>
  116. </el-form-item>
  117. <el-form-item label="项目类型" prop="flag">
  118. <el-radio v-model="flag" label="1">在建</el-radio>
  119. <el-radio v-model="flag" label="2">施工</el-radio>
  120. </el-form-item>
  121. <el-form-item label="项目小类" prop="subdivision">
  122. <el-select v-model="form.subdivision" placeholder="请选择">
  123. <el-option
  124. v-if="flag === '1'"
  125. v-for="item in typeListA"
  126. :key="item.key"
  127. :label="item.name"
  128. :value="item.key"/>
  129. <el-option
  130. v-if="flag === '2'"
  131. v-for="item in typeListB"
  132. :key="item.key"
  133. :label="item.name"
  134. :value="item.key"/>
  135. </el-select>
  136. </el-form-item>
  137. </el-form>
  138. <div slot="footer" class="dialog-footer">
  139. <el-button type="primary" @click="submitForm">确 定</el-button>
  140. <el-button @click="cancel">取 消</el-button>
  141. </div>
  142. </el-dialog>
  143. </div>
  144. </template>
  145. <script>
  146. import { listProject, getProject, delProject, addProject, updateProject } from "@/api/zcustom/project";
  147. import { getListTree, listPlatAppOrg } from '@/api/zcustom/platAppOrg'
  148. export default {
  149. name: "Project",
  150. data() {
  151. return {
  152. props:{
  153. value: 'appOrg',
  154. label: 'appName',
  155. checkStrictly: true,
  156. emitPath: false
  157. },
  158. treeList:[],
  159. typeListA:[
  160. {
  161. key: 1,
  162. name:'可研评审'
  163. },
  164. {
  165. key: 2,
  166. name:'初设评审'
  167. },
  168. {
  169. key: 3,
  170. name:'政府立项备案'
  171. },
  172. {
  173. key: 4,
  174. name:'土地手续'
  175. },
  176. {
  177. key: 5,
  178. name:'用地规划'
  179. },
  180. {
  181. key: 6,
  182. name:'工程规划'
  183. },
  184. {
  185. key: 7,
  186. name:'设计招标'
  187. },
  188. {
  189. key: 8,
  190. name:'施工招标'
  191. },
  192. {
  193. key: 9,
  194. name:'监理招标'
  195. },
  196. {
  197. key: 10,
  198. name:'施工许可'
  199. },
  200. ],
  201. typeListB:[
  202. {
  203. key: 11,
  204. name:'基础施工'
  205. },
  206. {
  207. key: 12,
  208. name:'主体工程'
  209. },
  210. {
  211. key: 13,
  212. name:'室内外装修'
  213. },
  214. {
  215. key: 14,
  216. name:'室外工程'
  217. }
  218. ],
  219. flag: '1',
  220. // 根路径
  221. baseURL: process.env.VUE_APP_BASE_API,
  222. // 遮罩层
  223. loading: true,
  224. // 选中数组
  225. ids: [],
  226. // 非单个禁用
  227. single: true,
  228. // 非多个禁用
  229. multiple: true,
  230. // 显示搜索条件
  231. showSearch: true,
  232. // 总条数
  233. total: 0,
  234. // 工程项目表格数据
  235. projectList: [],
  236. platAppOrgList: [],
  237. // 弹出层标题
  238. title: "",
  239. // 是否显示弹出层
  240. open: false,
  241. // 查询参数
  242. queryParams: {
  243. pageNum: 1,
  244. pageSize: 10,
  245. projectName: null,
  246. unitCode: null,
  247. connectFlag: null,
  248. },
  249. // 表单参数
  250. form: {},
  251. // 表单校验
  252. rules: {
  253. abscissa: [
  254. { required: true, message: "横坐标不能为空", trigger: "blur" }
  255. ],
  256. ordinate: [
  257. { required: true, message: "纵坐标不能为空", trigger: "blur" }
  258. ],
  259. subdivision: [
  260. { required: true, message: "项目小类不能为空", trigger: "blur" }
  261. ],
  262. projectName: [
  263. { required: true, message: "项目名称不能为空", trigger: "blur" }
  264. ],
  265. appOrg: [
  266. { required: true, message: "所属单位id不能为空", trigger: "blur" }
  267. ],
  268. supervisionUnit: [
  269. { required: true, message: "监理单位不能为空", trigger: "blur" }
  270. ],
  271. constructionUnit: [
  272. { required: true, message: "施工单位不能为空", trigger: "blur" }
  273. ]
  274. }
  275. };
  276. },
  277. created() {
  278. this.getList();
  279. this.getUnitList()
  280. this.getListTree();
  281. },
  282. methods: {
  283. /** 查询工程项目列表 */
  284. getList() {
  285. this.loading = true;
  286. listProject(this.queryParams).then(response => {
  287. this.projectList = response.data.records;
  288. this.total = response.data.total;
  289. this.loading = false;
  290. });
  291. },
  292. getListTree(){
  293. getListTree().then(res => {
  294. this.treeList.push(res.data)
  295. })
  296. },
  297. getUnitList() {
  298. listPlatAppOrg().then(response => {
  299. this.platAppOrgList = response.data.records;
  300. });
  301. },
  302. // 取消按钮
  303. cancel() {
  304. this.open = false;
  305. this.reset();
  306. },
  307. // 表单重置
  308. reset() {
  309. this.form = {
  310. id: null,
  311. projectName: null,
  312. unitCode: null,
  313. connectFlag: null,
  314. delFlag: null,
  315. };
  316. this.resetForm("form");
  317. },
  318. /** 搜索按钮操作 */
  319. handleQuery() {
  320. this.queryParams.pageNum = 1;
  321. this.getList();
  322. },
  323. /** 重置按钮操作 */
  324. resetQuery() {
  325. this.resetForm("queryForm");
  326. this.handleQuery();
  327. },
  328. // 多选框选中数据
  329. handleSelectionChange(selection) {
  330. this.ids = selection.map(item => item.id)
  331. this.single = selection.length!==1
  332. this.multiple = !selection.length
  333. },
  334. /** 新增按钮操作 */
  335. handleAdd() {
  336. this.reset();
  337. this.open = true;
  338. this.title = "添加工程项目";
  339. },
  340. /** 修改按钮操作 */
  341. handleUpdate(row) {
  342. this.reset();
  343. this.flag = Number(row.subdivision) < 10 ? '1' : '2'
  344. const id = row.id || this.ids
  345. getProject(id).then(response => {
  346. this.form = response.data;
  347. this.open = true;
  348. this.title = "修改工程项目";
  349. });
  350. },
  351. /** 提交按钮 */
  352. submitForm() {
  353. this.$refs["form"].validate(valid => {
  354. if (valid) {
  355. if (this.form.id != null) {
  356. updateProject(this.form).then(response => {
  357. this.$modal.msgSuccess("修改成功");
  358. this.open = false;
  359. this.getList();
  360. });
  361. } else {
  362. addProject(this.form).then(response => {
  363. this.$modal.msgSuccess("新增成功");
  364. this.open = false;
  365. this.getList();
  366. });
  367. }
  368. }
  369. });
  370. },
  371. /** 删除按钮操作 */
  372. handleDelete(row) {
  373. const ids = row.id || this.ids;
  374. this.$modal.confirm('是否确认删除?').then(function() {
  375. return delProject(ids);
  376. }).then(() => {
  377. this.getList();
  378. this.$modal.msgSuccess("删除成功");
  379. }).catch(() => {});
  380. },
  381. }
  382. };
  383. </script>