create.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div>
  3. <el-form
  4. ref="form"
  5. :model="form"
  6. :rules="rules"
  7. label-width="100px"
  8. class="create-form"
  9. >
  10. <el-row :gutter="15">
  11. <headerTitle style="margin-top: 15px" title="基本信息"></headerTitle>
  12. <questionInfo
  13. ref="info"
  14. v-if="form.objType == 1"
  15. :disabled="type == 'detail'"
  16. />
  17. <changeInfo
  18. ref="info"
  19. v-if="form.objType == 2"
  20. :disabled="type == 'detail'"
  21. />
  22. <noticeInfo
  23. ref="info"
  24. v-if="form.objType == 3"
  25. :disabled="type == 'detail'"
  26. />
  27. </el-row>
  28. <el-row :gutter="15">
  29. <headerTitle style="margin-top: 15px" title="关联变更"></headerTitle>
  30. <ele-pro-table
  31. ref="table"
  32. :columns="questionColumns"
  33. :datasource="this.form.relationObjList"
  34. height="10vh"
  35. :selection.sync="selection"
  36. :needPage="false"
  37. >
  38. <template v-slot:category="{ row }">
  39. <span v-for="item in row.category.split(',')" :key="item">
  40. {{ getDictValue('问题类型', item) }}</span
  41. >
  42. </template>
  43. <template v-slot:type="{ row }">
  44. <span>{{ getDictValue('变更类型', row.type + '') }}</span>
  45. </template>
  46. <template v-slot:toolbar>
  47. <el-button
  48. v-if="type != 'detail'"
  49. size="small"
  50. @click="del('selection', 'relationObjList')"
  51. >移除</el-button
  52. ></template
  53. >
  54. </ele-pro-table>
  55. <div
  56. class="add-product"
  57. v-if="type != 'detail'"
  58. @click="addEquipment('EquipmentDialogRef', 'relationObjList')"
  59. >
  60. <i class="el-icon-circle-plus-outline"></i>
  61. </div>
  62. </el-row>
  63. <el-row :gutter="15">
  64. <headerTitle style="margin-top: 15px" title="问题对象"></headerTitle>
  65. <ele-pro-table
  66. ref="table"
  67. :columns="objColumns"
  68. :datasource="this.form.problemObjList"
  69. height="10vh"
  70. :selection.sync="objSelection"
  71. :needPage="false"
  72. >
  73. <template v-slot:toolbar>
  74. <el-button
  75. v-if="type != 'detail'"
  76. size="small"
  77. @click="del('objSelection', 'problemObjList')"
  78. >移除</el-button
  79. ></template
  80. >
  81. </ele-pro-table>
  82. <div
  83. v-if="type != 'detail'"
  84. class="add-product"
  85. @click="addEquipment('objEquipmentDialogRef', 'problemObjList')"
  86. >
  87. <i class="el-icon-circle-plus-outline"></i>
  88. </div>
  89. </el-row>
  90. <el-row :gutter="15">
  91. <headerTitle style="margin-top: 15px" title="影响对象"></headerTitle>
  92. <ele-pro-table
  93. ref="table"
  94. :columns="objColumns"
  95. :datasource="this.form.influenceObjList"
  96. height="10vh"
  97. :selection.sync="influenceSelection"
  98. :needPage="false"
  99. >
  100. <template v-slot:toolbar>
  101. <el-button
  102. v-if="type != 'detail'"
  103. size="small"
  104. @click="del('influenceSelection', 'influenceObjList')"
  105. >移除</el-button
  106. ></template
  107. >
  108. </ele-pro-table>
  109. <div
  110. v-if="type != 'detail'"
  111. class="add-product"
  112. @click="addEquipment('objEquipmentDialogRef', 'influenceObjList')"
  113. >
  114. <i class="el-icon-circle-plus-outline"></i>
  115. </div>
  116. </el-row>
  117. <el-row :gutter="15">
  118. <headerTitle style="margin-top: 15px" title="参考对象"></headerTitle>
  119. <ele-pro-table
  120. ref="table"
  121. :columns="objColumns"
  122. :datasource="this.form.referenceObjList"
  123. height="10vh"
  124. :selection.sync="influenceSelection"
  125. :needPage="false"
  126. >
  127. <template v-slot:toolbar>
  128. <el-button
  129. size="small"
  130. v-if="type != 'detail'"
  131. @click="del('referenceSelection', 'referenceObjList')"
  132. >移除</el-button
  133. ></template
  134. >
  135. </ele-pro-table>
  136. <div
  137. v-if="type != 'detail'"
  138. class="add-product"
  139. @click="addEquipment('objEquipmentDialogRef', 'referenceObjList')"
  140. >
  141. <i class="el-icon-circle-plus-outline"></i>
  142. </div>
  143. </el-row>
  144. </el-form>
  145. <EquipmentDialog ref="EquipmentDialogRef" @choose="choose" />
  146. <objEquipmentDialog ref="objEquipmentDialogRef" @choose="choose" />
  147. </div>
  148. </template>
  149. <script>
  150. import questionInfo from './questionInfo';
  151. import changeInfo from './changeInfo';
  152. import noticeInfo from './noticeInfo';
  153. import EquipmentDialog from './EquipmentDialog';
  154. import objEquipmentDialog from './objEquipmentDialog';
  155. import dictMixins from '@/mixins/dictMixins';
  156. import { questionDetails } from '@/api/bpm/components/changeManagement/question';
  157. import { requestDetails } from '@/api/bpm/components/changeManagement/request';
  158. import { noticeDetails } from '@/api/bpm/components/changeManagement/notice';
  159. import { questionColumns, objColumns } from './data.js';
  160. const defaultForm = function () {
  161. return {
  162. relationObjList: [],
  163. problemObjList: [],
  164. influenceObjList: [],
  165. referenceObjList: []
  166. };
  167. };
  168. export default {
  169. mixins: [dictMixins],
  170. components: {
  171. // workOrder,
  172. // produceOrder,
  173. questionInfo,
  174. // productionPlan,
  175. EquipmentDialog,
  176. objEquipmentDialog,
  177. changeInfo,
  178. noticeInfo
  179. },
  180. data() {
  181. //关联对象类型 objType 1:生产计划 2:生产订单 3:生产工单
  182. //关联变更类型 objType 1:问题报告 2:变更申请 3:变更通知
  183. return {
  184. questionColumns: questionColumns.filter(
  185. (item) => item.columnKey != 'action'
  186. ),
  187. objColumns,
  188. visible: false,
  189. loading: false,
  190. form: { ...defaultForm() },
  191. // 表单验证规则
  192. rules: {
  193. type: [{ required: true, message: '请选择', trigger: 'change' }],
  194. name: [{ required: true, message: '请选择', trigger: 'change' }],
  195. relationType: [{ required: true, message: '请选择', trigger: 'change' }]
  196. },
  197. activeList: '',
  198. type: '',
  199. title: '创建',
  200. selection: [],
  201. influenceSelection: [],
  202. objSelection: [],
  203. referenceSelection: []
  204. };
  205. },
  206. props: {
  207. businessId: {
  208. default: ''
  209. },
  210. processDefinitionId: {
  211. default: ''
  212. },
  213. taskDefinitionKey: {
  214. default: ''
  215. }
  216. },
  217. computed: {
  218. // 是否开启响应式布局
  219. styleResponsive() {
  220. return this.$store.state.theme.styleResponsive;
  221. }
  222. },
  223. created() {
  224. this.init();
  225. },
  226. methods: {
  227. del(selection, list) {
  228. let ids = this[selection].map((item) => item.id);
  229. this.form[list] = this.form[list].filter(
  230. (item) => !ids.includes(item.id)
  231. );
  232. },
  233. addEquipment(ref, list) {
  234. this.activeList = list;
  235. this.$refs[ref].open(this.form[list]);
  236. },
  237. async init() {
  238. let api = this.processDefinitionId.includes('change_notice_approve')
  239. ? noticeDetails
  240. : this.processDefinitionId.includes('change_request_approve')
  241. ? requestDetails
  242. : questionDetails;
  243. let data = await api(this.businessId);
  244. this.type = this.taskDefinitionKey == 'starter' ? 'edit' : 'detail';
  245. this.form = JSON.parse(JSON.stringify(data));
  246. this.form.category = this.form.category.split(',');
  247. this.form.type = this.form.type + '';
  248. this.$nextTick(() => {
  249. this.$refs.info.setValue(this.form);
  250. });
  251. },
  252. choose(data) {
  253. this.form[this.activeList] = data;
  254. if (this.activeList == 'relationObjList') {
  255. this.getChangeData();
  256. }
  257. },
  258. getChangeData() {
  259. ['problemObjList', 'influenceObjList', 'referenceObjList'].forEach(
  260. (key) => {
  261. this.form[key] = [];
  262. }
  263. );
  264. //获取关联数据
  265. this.form.relationObjList.forEach(async (item) => {
  266. let api =
  267. item.objType == 1
  268. ? questionDetails
  269. : item.objType == 2
  270. ? requestDetails
  271. : noticeDetails;
  272. const data = await api(item.id);
  273. ['problemObjList', 'influenceObjList', 'referenceObjList'].forEach(
  274. (key) => {
  275. this.form[key].push(...data[key]);
  276. }
  277. );
  278. });
  279. },
  280. /* 保存编辑 */
  281. async getTableValue() {
  282. // let data = JSON.parse(JSON.stringify(this.form));
  283. let infoData = await this.$refs.info.getValue();
  284. if (!infoData) {
  285. return;
  286. }
  287. infoData.category = infoData.category.toString();
  288. Object.assign(infoData, {
  289. relationObjList: this.form.relationObjList,
  290. problemObjList: this.form.problemObjList,
  291. influenceObjList: this.form.influenceObjList,
  292. referenceObjList: this.form.referenceObjList
  293. });
  294. return infoData;
  295. }
  296. }
  297. };
  298. </script>
  299. <style lang="scss" scoped>
  300. .add-product {
  301. width: 100%;
  302. display: flex;
  303. align-items: center;
  304. justify-content: flex-end;
  305. font-size: 30px;
  306. color: #1890ff;
  307. margin: 10px 0;
  308. cursor: pointer;
  309. }
  310. .create-form .el-form-item {
  311. margin-bottom: 15px !important;
  312. }
  313. </style>