redeployOther.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. title="转派工单"
  5. width="60%"
  6. :modal="false"
  7. :fullscreen="fullscreen"
  8. class="fullscreen"
  9. >
  10. <template slot="title">
  11. <modalTitle
  12. title="转派工单"
  13. @setFullscreen="fullscreen = !fullscreen"
  14. ></modalTitle>
  15. </template>
  16. <div class="sparepart-apply">
  17. <el-tabs
  18. v-model="tabValue"
  19. class="demo-monitor-tabs"
  20. @tab-click="handleClickTab"
  21. >
  22. <el-tab-pane label="执行人" name="0" />
  23. <el-tab-pane label="班组" name="1" />
  24. </el-tabs>
  25. <div class="select-box">
  26. <el-form label-width="80px">
  27. <el-row :gutter="24">
  28. <el-col :span="12">
  29. <el-form-item label="工单单号">
  30. <el-input v-model="row.code" disabled></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12" v-if="tabValue == '1'">
  34. <el-form-item label="班组">
  35. <el-select
  36. v-model="teamId"
  37. size="small"
  38. @change="teamChange"
  39. style="width: 100%"
  40. >
  41. <el-option
  42. :value="i.id"
  43. :label="i.name"
  44. v-for="i in teamAllList"
  45. :key="i.id"
  46. ></el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. <template v-if="tabValue == '0'">
  51. <el-col :span="12">
  52. <el-form-item label="部门">
  53. <deptSelect v-model="groupId" @changeGroup="deptClick" />
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="12">
  57. <el-form-item label="" label-width="10px">
  58. <el-input v-model="name" placeholder="搜索姓名"></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="12" style="text-align: right">
  62. <el-form-item label="" label-width="10px">
  63. <el-button
  64. @click="search"
  65. type="primary"
  66. icon="el-icon-search"
  67. >搜索</el-button
  68. >
  69. <el-button @click="reset" icon="el-icon-refresh-left"
  70. >重置</el-button
  71. >
  72. </el-form-item>
  73. </el-col>
  74. </template>
  75. </el-row>
  76. </el-form>
  77. </div>
  78. <div v-if="tabValue == '0'" class="data-tab">
  79. <ele-pro-table
  80. ref="tableRef2"
  81. row-key="id"
  82. :columns="columns"
  83. :datasource="datasource"
  84. cache-key="redeployOther"
  85. :header-cell-class-name="headerCellClassName"
  86. :selection.sync="selection"
  87. >
  88. </ele-pro-table>
  89. </div>
  90. </div>
  91. <div slot="footer" class="footer">
  92. <el-button @click="cancel">返回</el-button>
  93. <el-button
  94. v-if="entranceValue == 'transfer'"
  95. :loading="btnLoading"
  96. type="primary"
  97. @click="submit"
  98. >提交</el-button
  99. >
  100. <el-button
  101. v-if="entranceValue == 'noFinishSubmit'"
  102. :loading="btnLoading"
  103. type="primary"
  104. @click="confirm"
  105. >确认</el-button
  106. >
  107. </div>
  108. </el-dialog>
  109. </template>
  110. <script>
  111. import modalTitle from '@/components/modalTitle.vue';
  112. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  113. import { getUserPage } from '@/api/system/organization';
  114. import { recordrulesplanReManualDispatchOrder } from '@/api/recordRules/index';
  115. import { getteampage } from '@/api/workforceManagement/team';
  116. export default {
  117. components: { deptSelect, modalTitle },
  118. props: {},
  119. data() {
  120. return {
  121. fullscreen: false,
  122. btnLoading: false,
  123. visible: false,
  124. treeList: [],
  125. pages: {
  126. pageNum: 1,
  127. size: 15
  128. },
  129. total: 0,
  130. selectedRow: {},
  131. selectedRowData: [],
  132. groupId: '',
  133. executorDeptName: '',
  134. name: '',
  135. row: {},
  136. columns: [
  137. {
  138. width: 45,
  139. type: 'selection',
  140. columnKey: 'selection',
  141. align: 'center'
  142. // selectable: (row, index) => {
  143. // return row.id !== this.row.executeUserId;
  144. // }
  145. },
  146. {
  147. columnKey: 'index',
  148. label: '序号',
  149. type: 'index',
  150. width: 55,
  151. align: 'center',
  152. showOverflowTooltip: true,
  153. fixed: 'left'
  154. },
  155. {
  156. prop: 'jobNumber',
  157. label: '工号',
  158. align: 'center',
  159. showOverflowTooltip: true
  160. },
  161. {
  162. prop: 'name',
  163. label: '姓名',
  164. align: 'center',
  165. showOverflowTooltip: true
  166. },
  167. {
  168. prop: 'phone',
  169. label: '电话',
  170. align: 'center',
  171. showOverflowTooltip: true
  172. },
  173. {
  174. prop: 'groupName',
  175. label: '部门',
  176. align: 'center',
  177. showOverflowTooltip: true
  178. }
  179. ],
  180. tabValue: '',
  181. selectedRowDataId: '',
  182. tableData: [],
  183. // arry: [],
  184. entranceValue: '',
  185. selection: [],
  186. teamAllList: [],
  187. teamId: '',
  188. executeUser: []
  189. };
  190. },
  191. created() {
  192. this.getList();
  193. this.getAllTeamList();
  194. },
  195. methods: {
  196. async getList() {
  197. const data = await getUserPage({
  198. pageNum: 1,
  199. size: -1,
  200. groupId: '',
  201. name: '',
  202. groupId: this.groupId
  203. });
  204. this.tableData = data.list;
  205. },
  206. handleClickTab(tab, event) {
  207. this.selectedRow = {};
  208. this.selectedRowData = [];
  209. this.tabValue = tab.name;
  210. this.$refs.tableRef2?.clearSelection();
  211. },
  212. open(row, val = 'transfer') {
  213. this.entranceValue = val;
  214. // 转派
  215. if (val == 'transfer') {
  216. if (row.planExecuteType == '1') {
  217. // 班组
  218. this.tabValue = '1';
  219. } else {
  220. this.tabValue = '0';
  221. }
  222. }
  223. this.row = row;
  224. this.name = '';
  225. this.groupId = '';
  226. this.executorDeptName = '';
  227. this.visible = true;
  228. this.$nextTick(() => {
  229. this.$refs.tableRef2?.clearSelection();
  230. });
  231. },
  232. //重置
  233. reset() {
  234. this.name = '';
  235. this.search();
  236. },
  237. // 搜索
  238. search() {
  239. this.$refs.tableRef2.reload();
  240. },
  241. deptClick(data) {
  242. if (data) {
  243. this.$refs.tableRef2.reload();
  244. }
  245. },
  246. // 获取审核人列表、巡点检人员
  247. async datasource({ page, limit, where, order }) {
  248. this.selectedRow = {};
  249. // 如果传了参数就是获取巡点检人员数据
  250. return getUserPage({
  251. pageNum: page,
  252. size: limit,
  253. ...where,
  254. groupId: this.groupId,
  255. name: this.name
  256. });
  257. },
  258. handleSelectAll(selection) {
  259. this.$refs.tableRef2.clearSelection();
  260. },
  261. headerCellClassName({ columnIndex }) {
  262. // 如果是第一列(通常是全选框),则返回自定义的class名
  263. if (columnIndex === 0) {
  264. return 'hide-selection-checkbox';
  265. }
  266. return '';
  267. },
  268. async submit() {
  269. if (this.tabValue == '0' && this.selection.length == 0) {
  270. return this.$message.warning('请选择转派人员');
  271. }
  272. if (this.tabValue == '1' && !this.teamId) {
  273. return this.$message.warning('请选择班组');
  274. }
  275. let executeUser = null;
  276. if (this.tabValue == '0') {
  277. executeUser = this.selection.map((i) => {
  278. return {
  279. groupId: i.groupId,
  280. groupName: i.groupName,
  281. userId: i.id,
  282. userName: i.name
  283. };
  284. });
  285. } else {
  286. executeUser = this.executeUser;
  287. }
  288. this.btnLoading = true;
  289. let params = {
  290. executeUser,
  291. id: this.row.planId,
  292. // 0个人 1班组
  293. type: this.tabValue
  294. };
  295. recordrulesplanReManualDispatchOrder(params)
  296. .then(() => {
  297. this.$message.success(`该工单成功转派`);
  298. this.visible = false;
  299. this.$emit('refresh');
  300. this.btnLoading = false;
  301. })
  302. .catch(() => {
  303. this.btnLoading = false;
  304. });
  305. },
  306. confirm() {
  307. this.visible = false;
  308. this.$emit('confirm', this.selectedRow);
  309. },
  310. cancel() {
  311. this.tabValue = '0';
  312. this.selectedRow = {};
  313. this.selectedRowData = [];
  314. this.selection = [];
  315. this.executeUser = [];
  316. this.visible = false;
  317. },
  318. async getAllTeamList() {
  319. const { list } = await getteampage({
  320. pageNum: 1,
  321. size: -1
  322. });
  323. console.log('teamAllList 班组', list);
  324. this.teamAllList = list;
  325. },
  326. teamChange() {
  327. console.log('this.teamId', this.teamId);
  328. // 当前班组
  329. const currentTeam = this.teamAllList.find(
  330. (item) => item.id === this.teamId
  331. );
  332. if (currentTeam) {
  333. // 同步执行人
  334. this.executeUser = [
  335. {
  336. teamId: currentTeam.id,
  337. teamName: currentTeam.name
  338. }
  339. ];
  340. }
  341. }
  342. }
  343. };
  344. </script>
  345. <style lang="scss" scoped>
  346. .sparepart-apply {
  347. .select-box {
  348. padding: 10px 0;
  349. }
  350. .material-item + .material-item {
  351. margin-top: 10px;
  352. }
  353. }
  354. .flex-between {
  355. display: flex;
  356. justify-content: space-between;
  357. padding-right: 20%;
  358. }
  359. .list-box {
  360. max-height: 60vh;
  361. overflow-y: auto;
  362. overflow-x: hidden;
  363. }
  364. .footer {
  365. padding: 10px;
  366. text-align: right;
  367. background: #fff;
  368. display: flex;
  369. align-items: center;
  370. justify-content: center;
  371. }
  372. ::v-deep .hide-selection-checkbox .cell .el-checkbox {
  373. // visibility: hidden !important;
  374. }
  375. </style>