inspectionProjectTaskSend.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <ele-modal
  3. width="70%"
  4. :append-to-body="true"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form"
  7. :title="type == 1 ? '质检项派单' : '质检项请托'"
  8. :visible.sync="visible"
  9. :maxable="true"
  10. @close="cancel"
  11. >
  12. <header-title title="质检项信息"></header-title>
  13. <ele-pro-table
  14. :needPage="false"
  15. :columns="tableColumns"
  16. :datasource="list"
  17. :selection.sync="selection"
  18. rowKey="id"
  19. ref="table"
  20. ></ele-pro-table>
  21. <header-title title="派单信息"></header-title>
  22. <el-form
  23. ref="form"
  24. :model="form"
  25. :rules="rules"
  26. class="el-form-box"
  27. label-width="120px"
  28. >
  29. <el-row>
  30. <el-col :span="8">
  31. <el-form-item
  32. :label="type == 1 ? '任务单号' : '质检项请托单号'"
  33. prop="code"
  34. >
  35. <el-input
  36. v-model="form.code"
  37. placeholder=" "
  38. disabled
  39. ></el-input> </el-form-item
  40. ></el-col>
  41. <el-col :span="8">
  42. <el-form-item label="任务名称" prop="name">
  43. <el-input
  44. v-model="form.name"
  45. placeholder="请输入"
  46. ></el-input> </el-form-item></el-col
  47. ></el-row>
  48. <el-row>
  49. <el-col :span="8">
  50. <el-form-item label="执行部门" prop="executeDeptId">
  51. <deptSelect
  52. v-model="form.executeDeptId"
  53. @changeGroup="searchDeptNodeClick"
  54. /> </el-form-item
  55. ></el-col>
  56. <el-col :span="8">
  57. <el-form-item label="执行人" prop="executeUserId">
  58. <el-select
  59. v-model="form.executeUserId"
  60. @change="changeExecutor"
  61. filterable
  62. style="width: 100%"
  63. >
  64. <el-option
  65. v-for="item in executorList"
  66. :key="item.id"
  67. :value="item.id"
  68. :label="item.name"
  69. ></el-option>
  70. </el-select> </el-form-item></el-col
  71. ></el-row>
  72. <el-row>
  73. <el-col :span="8">
  74. <el-form-item label="要求完成时间" prop="requiredCompletionTime">
  75. <el-date-picker
  76. v-model="form.requiredCompletionTime"
  77. style="width: 100%"
  78. type="datetime"
  79. value-format="yyyy-MM-dd HH:mm:ss"
  80. placeholder=" "
  81. >
  82. </el-date-picker> </el-form-item
  83. ></el-col>
  84. </el-row>
  85. </el-form>
  86. <template v-slot:footer>
  87. <el-button @click="cancel">取消</el-button>
  88. <el-button type="primary" :loading="loading" @click="save">
  89. 确认
  90. </el-button>
  91. </template>
  92. </ele-modal>
  93. </template>
  94. <script>
  95. import {
  96. qualityInspectionItemDispatching,
  97. qualityInspectionItemRequest
  98. } from '@/api/inspectionProjectTask';
  99. import { getById } from '@/api/inspectionWork';
  100. import {
  101. getById as getQualityInspectionItemById,
  102. updateRequestentrust
  103. } from '@/api/inspectionProjectRequest';
  104. import { inspectionProjectStatus } from '@/enum/dict.js';
  105. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  106. import { getUserPage } from '@/api/system/organization';
  107. const defaultForm = {
  108. id: null,
  109. executeDeptId: '',
  110. executeDeptName: '',
  111. executeUserId: '',
  112. executeUserName: '',
  113. name: '',
  114. code: '',
  115. qualityWorkOrderId: '',
  116. requiredCompletionTime: '',
  117. type: 1
  118. };
  119. export default {
  120. components: { deptSelect },
  121. data() {
  122. return {
  123. type: 1,
  124. pgaeName: '',
  125. form: { ...defaultForm },
  126. executorList: [],
  127. selection: [],
  128. list: [],
  129. tableColumns: [
  130. {
  131. width: 45,
  132. type: 'index',
  133. columnKey: 'index',
  134. align: 'center',
  135. fixed: 'left'
  136. },
  137. {
  138. width: 45,
  139. type: 'selection',
  140. columnKey: 'selection',
  141. align: 'center',
  142. selectable: (row, index) => {
  143. return row.status == 0 || this.templateIdS.includes(row.id);
  144. }
  145. },
  146. {
  147. minWidth: 150,
  148. prop: 'qualitySchemeTemplateCode',
  149. align: 'center',
  150. label: '质检方案编码',
  151. showOverflowTooltip: true
  152. },
  153. {
  154. minWidth: 120,
  155. prop: 'qualitySchemeTemplateName',
  156. align: 'center',
  157. label: '质检方案名称',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. minWidth: 100,
  162. prop: 'categoryLevelClassName',
  163. align: 'center',
  164. label: '质检类型',
  165. showOverflowTooltip: true
  166. },
  167. {
  168. minWidth: 130,
  169. prop: 'inspectionCode',
  170. align: 'center',
  171. label: '质检项编码',
  172. showOverflowTooltip: true
  173. },
  174. {
  175. minWidth: 120,
  176. prop: 'inspectionName',
  177. align: 'center',
  178. label: '质检项名称',
  179. showOverflowTooltip: true
  180. },
  181. {
  182. minWidth: 150,
  183. prop: 'defaultValue',
  184. align: 'center',
  185. label: '工艺参数',
  186. showOverflowTooltip: true
  187. },
  188. {
  189. minWidth: 150,
  190. prop: 'status',
  191. align: 'center',
  192. formatter: (row) => {
  193. return (
  194. inspectionProjectStatus.find(
  195. (item) => item.value === row.status
  196. )?.label || ''
  197. );
  198. },
  199. label: '状态',
  200. showOverflowTooltip: true
  201. }
  202. ],
  203. rules: {
  204. executeDeptId: [
  205. { required: true, message: '请选择部门', trigger: 'blur' }
  206. ],
  207. name: [
  208. { required: true, message: '请输入任务名称', trigger: 'blur' }
  209. ],
  210. requiredCompletionTime: [
  211. { required: true, message: '请输入要求完成日期', trigger: 'blur' }
  212. ],
  213. executeUserId: [
  214. { required: true, message: '请选择人员', trigger: 'blur' }
  215. ]
  216. },
  217. templateIdS: [],
  218. loading: false,
  219. visible: false
  220. };
  221. },
  222. created() {},
  223. methods: {
  224. async open(row, type, pgaeName) {
  225. this.type = type;
  226. this.pgaeName = pgaeName;
  227. this.visible = true;
  228. this.templateIdS = [];
  229. if (pgaeName == 'inspectionProjectRequest') {
  230. this.form = await getQualityInspectionItemById(row.id);
  231. this.getUserList({ groupId: this.form.executeDeptId }, true);
  232. if (this.form.templateList.length) {
  233. this.templateIdS = this.form.templateList.map((item) => item.id);
  234. }
  235. } else {
  236. this.form.qualityWorkOrderId = row.id;
  237. }
  238. //获取工单质检方案
  239. await getById(this.form.qualityWorkOrderId).then((res) => {
  240. this.list = res.data.templateList;
  241. this.$nextTick(() => {
  242. this.$refs.table.setSelectedRowKeys(this.templateIdS);
  243. });
  244. });
  245. },
  246. searchDeptNodeClick(info, row) {
  247. if (info) {
  248. const params = { groupId: info };
  249. this.form.executeDeptId = info;
  250. this.form.executeDeptName = row.name;
  251. this.getUserList(params);
  252. } else {
  253. this.form.executeUserId = null;
  254. this.form.executeUserName = null;
  255. this.executorList = [];
  256. }
  257. },
  258. // 获取人员
  259. async getUserList(params, init) {
  260. try {
  261. let data = { pageNum: 1, size: -1 };
  262. if (params) {
  263. data = Object.assign(data, params);
  264. }
  265. const res = await getUserPage(data);
  266. this.executorList = res.list;
  267. if (init) {
  268. return;
  269. }
  270. this.form.executeUserId = null;
  271. this.form.executeUserName = null;
  272. } catch (error) {}
  273. },
  274. changeExecutor(val) {
  275. if (val) {
  276. this.form.executeUserId = val;
  277. this.form.executeUserName = this.executorList.find(
  278. (item) => item.id === val
  279. ).name;
  280. }
  281. },
  282. save() {
  283. this.$refs.form.validate((valid) => {
  284. if (!valid) {
  285. return false;
  286. }
  287. if (this.selection.length == 0) {
  288. return this.$message.warning('请至少选择一条数据');
  289. }
  290. this.loading = true;
  291. let api =
  292. this.type == 1
  293. ? qualityInspectionItemDispatching
  294. : this.type == 2
  295. ? this.pgaeName == 'inspectionProjectRequest'
  296. ? updateRequestentrust
  297. : qualityInspectionItemRequest
  298. : '';
  299. api({
  300. ...this.form,
  301. detailList: this.selection.map((item) => {
  302. return { qualityPlanTemplateId: item.id };
  303. })
  304. })
  305. .then((msg) => {
  306. this.loading = false;
  307. this.$emit('reload');
  308. this.cancel();
  309. })
  310. .catch((e) => {
  311. this.loading = false;
  312. });
  313. });
  314. },
  315. cancel() {
  316. this.visible = false;
  317. this.$refs.form.clearValidate();
  318. this.form = { ...defaultForm };
  319. this.list = [];
  320. }
  321. }
  322. };
  323. </script>
  324. <style lang="scss" scoped></style>