index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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="applyNum">
  5. <el-input
  6. v-model="queryParams.applyNum"
  7. placeholder="请输入申请编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="高压停电" prop="highVoltage">
  14. <el-select v-model="queryParams.highVoltage" placeholder="请选择是否高压停电" clearable size="small">
  15. <el-option label="否" value="0" />
  16. <el-option label="是" value="1" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="申请人" prop="applyUserName">
  20. <el-input
  21. v-model="queryParams.applyUserName"
  22. placeholder="请输入申请人"
  23. clearable
  24. size="small"
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item label="申请时间" prop="applyTime">
  29. <el-date-picker clearable size="small" style="width: 200px"
  30. v-model="queryParams.applyTime"
  31. type="date"
  32. value-format="yyyy-MM-dd"
  33. placeholder="选择申请时间">
  34. </el-date-picker>
  35. </el-form-item>
  36. <el-form-item label="流程实例" prop="instanceId">
  37. <el-input
  38. v-model="queryParams.instanceId"
  39. placeholder="请输入流程实例ID"
  40. clearable
  41. size="small"
  42. @keyup.enter.native="handleQuery"
  43. />
  44. </el-form-item>
  45. <el-form-item>
  46. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  47. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  48. </el-form-item>
  49. </el-form>
  50. <el-row :gutter="10" class="mb8">
  51. <el-col :span="1.5">
  52. <el-button
  53. type="primary"
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['example:demo:add']"
  58. >新增</el-button>
  59. </el-col>
  60. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  61. </el-row>
  62. <el-table v-loading="loading" :data="demoList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="ID" align="center" prop="id" width="60" />
  65. <el-table-column label="申请编号" align="center" prop="applyNum" width="120" />
  66. <el-table-column label="是否高压停电" align="center" prop="highVoltage" width="100">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.highVoltage === '0' ? '否' : '是' }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="申请人" align="center" prop="applyUserName" width="90" />
  72. <el-table-column label="申请时间" align="center" prop="applyTime" width="180" />
  73. <el-table-column label="流程实例ID" align="center" prop="instanceId" width="100" />
  74. <el-table-column label="备注" align="center" prop="remark" width="180" />
  75. <el-table-column label="当前任务名称" align="center" prop="taskName" width="150" />
  76. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  77. <template slot-scope="scope">
  78. <!--本案例提交申请前有做会签参与人选择的操作,因此不引入 ApplyBefore 子组件-->
  79. <el-button
  80. v-show="!scope.row.instanceId"
  81. size="mini"
  82. type="text"
  83. icon="el-icon-check"
  84. @click="handleApplyView(scope.row)"
  85. >提交申请</el-button>
  86. <el-button
  87. v-show="!scope.row.instanceId"
  88. size="mini"
  89. type="text"
  90. icon="el-icon-edit"
  91. @click="handleUpdate(scope.row)"
  92. >修改</el-button>
  93. <el-button
  94. v-show="!scope.row.instanceId"
  95. size="mini"
  96. type="text"
  97. icon="el-icon-delete"
  98. @click="handleDelete(scope.row)"
  99. >删除</el-button>
  100. <apply-after
  101. v-show="scope.row.instanceId"
  102. :row="scope.row"
  103. :taskId="scope.row.taskId"
  104. :type="scope.row.type"
  105. @getList="getList"
  106. ></apply-after>
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <pagination
  111. v-show="total>0"
  112. :total="total"
  113. :page.sync="queryParams.pageNum"
  114. :limit.sync="queryParams.pageSize"
  115. @pagination="getList"
  116. />
  117. <!-- 添加或修改示例Demo对话框 -->
  118. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  119. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  120. <el-form-item label="申请编号" prop="applyNum">
  121. <el-input v-model="form.applyNum" placeholder="请输入申请编号" />
  122. </el-form-item>
  123. <el-form-item label="是否高压停电">
  124. <el-radio-group v-model="form.highVoltage">
  125. <el-radio label="0">否</el-radio>
  126. <el-radio label="1">是</el-radio>
  127. </el-radio-group>
  128. </el-form-item>
  129. <el-form-item label="备注" prop="remark">
  130. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  131. </el-form-item>
  132. </el-form>
  133. <div slot="footer" class="dialog-footer">
  134. <el-button type="primary" @click="submitForm">确 定</el-button>
  135. <el-button @click="cancel">取 消</el-button>
  136. </div>
  137. </el-dialog>
  138. <!--选择会签参与人对话框-->
  139. <el-dialog title="选择调度会会签参与人" :visible.sync="showSelectUser" width="400px" append-to-body>
  140. <el-form ref="selectUserForm" :rules="selectUserRules" label-width="80px">
  141. <el-form-item label="参与人">
  142. <el-select v-model="userNames" multiple placeholder="请选择">
  143. <el-option
  144. v-for="item in userOptions"
  145. :key="item.userId"
  146. :label="item.nickName"
  147. :value="item.userName"
  148. :disabled="item.status === 1"
  149. ></el-option>
  150. </el-select>
  151. </el-form-item>
  152. </el-form>
  153. <div slot="footer" class="dialog-footer">
  154. <el-button type="primary" @click="handleApply">确 定</el-button>
  155. <el-button @click="userNames=[];showSelectUser=false">取 消</el-button>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { listDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/example/demo";
  162. import ApplyBefore from "@/components/Activiti/ApplyBefore/index";
  163. import ApplyAfter from "@/components/Activiti/ApplyAfter/index";
  164. import { listUser } from "@/api/system/user";
  165. import request from '@/utils/request'
  166. export default {
  167. name: "Demo",
  168. components: {
  169. ApplyBefore,
  170. ApplyAfter,
  171. },
  172. data() {
  173. return {
  174. // 遮罩层
  175. loading: true,
  176. // 选中数组
  177. ids: [],
  178. // 非单个禁用
  179. single: true,
  180. // 非多个禁用
  181. multiple: true,
  182. // 显示搜索条件
  183. showSearch: true,
  184. // 总条数
  185. total: 0,
  186. // 示例Demo表格数据
  187. demoList: [],
  188. // 弹出层标题
  189. title: "",
  190. // 是否显示弹出层
  191. open: false,
  192. // 查询参数
  193. queryParams: {
  194. pageNum: 1,
  195. pageSize: 10,
  196. applyNum: null,
  197. highVoltage: null,
  198. attachment: null,
  199. applyUserId: null,
  200. applyUserName: null,
  201. applyTime: null,
  202. instanceId: null,
  203. },
  204. // 表单参数
  205. form: {},
  206. // 表单校验
  207. rules: {
  208. applyNum: [
  209. { required: true, message: "申请编号不能为空", trigger: "blur" }
  210. ],
  211. highVoltage: [
  212. { required: true, message: "是否高压停电不能为空", trigger: "blur" }
  213. ],
  214. },
  215. requestMapping: '/example/demo',
  216. selectedRow: {},
  217. selectUserForm: {},
  218. showSelectUser: false,
  219. selectUserRules: {
  220. userOptions: [
  221. { required: true, message: '参与人不能为空', trigger: 'blur' },
  222. ],
  223. },
  224. userOptions: [],
  225. userNames: [],
  226. };
  227. },
  228. created() {
  229. this.getList();
  230. },
  231. methods: {
  232. /** 查询示例Demo列表 */
  233. getList() {
  234. this.loading = true;
  235. listDemo(this.queryParams).then(response => {
  236. this.demoList = response.rows;
  237. this.total = response.total;
  238. this.loading = false;
  239. }).then(() => {
  240. });
  241. },
  242. // 取消按钮
  243. cancel() {
  244. this.open = false;
  245. this.reset();
  246. },
  247. // 表单重置
  248. reset() {
  249. this.form = {
  250. id: null,
  251. applyNum: null,
  252. highVoltage: "0",
  253. attachment: null,
  254. applyUserId: null,
  255. applyUserName: null,
  256. applyTime: null,
  257. instanceId: null,
  258. delFlag: null,
  259. createBy: null,
  260. createTime: null,
  261. updateBy: null,
  262. updateTime: null,
  263. remark: null
  264. };
  265. this.resetForm("form");
  266. },
  267. /** 搜索按钮操作 */
  268. handleQuery() {
  269. this.queryParams.pageNum = 1;
  270. this.getList();
  271. },
  272. /** 重置按钮操作 */
  273. resetQuery() {
  274. this.resetForm("queryForm");
  275. this.handleQuery();
  276. },
  277. // 多选框选中数据
  278. handleSelectionChange(selection) {
  279. this.ids = selection.map(item => item.id)
  280. this.single = selection.length!==1
  281. this.multiple = !selection.length
  282. },
  283. /** 新增按钮操作 */
  284. handleAdd() {
  285. this.reset();
  286. this.open = true;
  287. this.title = "添加示例Demo";
  288. },
  289. /** 修改按钮操作 */
  290. handleUpdate(row) {
  291. this.reset();
  292. const id = row.id || this.ids
  293. getDemo(id).then(response => {
  294. this.form = response.data;
  295. this.open = true;
  296. this.title = "修改示例Demo";
  297. });
  298. },
  299. /** 提交按钮 */
  300. submitForm() {
  301. this.$refs["form"].validate(valid => {
  302. if (valid) {
  303. if (this.form.id != null) {
  304. updateDemo(this.form).then(response => {
  305. this.msgSuccess("修改成功");
  306. this.open = false;
  307. this.getList();
  308. });
  309. } else {
  310. addDemo(this.form).then(response => {
  311. this.msgSuccess("新增成功");
  312. this.open = false;
  313. this.getList();
  314. });
  315. }
  316. }
  317. });
  318. },
  319. /** 删除按钮操作 */
  320. handleDelete(row) {
  321. const ids = row.id || this.ids;
  322. this.$confirm('是否确认删除示例Demo编号为"' + ids + '"的数据项?', "警告", {
  323. confirmButtonText: "确定",
  324. cancelButtonText: "取消",
  325. type: "warning"
  326. }).then(function() {
  327. return delDemo(ids);
  328. }).then(() => {
  329. this.getList();
  330. this.msgSuccess("删除成功");
  331. })
  332. },
  333. /** 导出按钮操作 */
  334. handleExport() {
  335. const queryParams = this.queryParams;
  336. this.$confirm('是否确认导出所有示例Demo数据项?', "警告", {
  337. confirmButtonText: "确定",
  338. cancelButtonText: "取消",
  339. type: "warning"
  340. }).then(function() {
  341. return exportDemo(queryParams);
  342. }).then(response => {
  343. this.download(response.msg);
  344. })
  345. },
  346. handleApply: function () {
  347. if (this.userNames.length === 0) {
  348. this.msgError('请先选择会签参与人');
  349. return;
  350. }
  351. const selectedRow = this.selectedRow;
  352. const requestMapping = this.requestMapping;
  353. const userNames = this.userNames.toString();
  354. this.$confirm('是否提交ID为"' + selectedRow.id + '"的申请单据?', "警告", {
  355. confirmButtonText: "确定",
  356. cancelButtonText: "取消",
  357. type: "warning"
  358. }).then(function() {
  359. return request({
  360. url: requestMapping + '/submitApply/' + selectedRow.id,
  361. method: 'post',
  362. params: { "variablesStr": { "gytd": selectedRow.highVoltage, "users": userNames } },
  363. });
  364. }).then(() => {
  365. this.getList();
  366. this.msgSuccess("申请成功");
  367. this.userNames = [];
  368. this.showSelectUser = false;
  369. })
  370. },
  371. handleApplyView(row) {
  372. this.selectedRow = row;
  373. this.showSelectUser = true;
  374. this.getUserList();
  375. },
  376. /** 查询用户列表 */
  377. getUserList() {
  378. listUser().then(response => {
  379. this.userOptions = response.rows;
  380. }
  381. );
  382. },
  383. }
  384. };
  385. </script>