taskinstanceDialog.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!-- 用户编辑弹窗 -->
  2. <template>
  3. <ele-modal
  4. width="1060px"
  5. :visible="visible"
  6. :append-to-body="true"
  7. :close-on-click-modal="false"
  8. custom-class="ele-dialog-form"
  9. title="工序"
  10. @update:visible="updateVisible(false)"
  11. >
  12. <header-title title="基本信息"> </header-title>
  13. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  14. <el-row>
  15. <el-col :span="8">
  16. <el-form-item label="加工方式:" prop="produceType">
  17. <el-select
  18. v-model="form.produceType"
  19. style="width: 100%"
  20. @change="changeProduceType"
  21. >
  22. <el-option
  23. v-for="item of producedList"
  24. :key="item.code"
  25. :label="item.name"
  26. :value="item.code"
  27. ></el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="8">
  32. <el-form-item label="BOM版本:" prop="bomCategoryId">
  33. <el-select
  34. v-model="form.bomCategoryId"
  35. style="width: 100%"
  36. @change="changeBomId"
  37. >
  38. <el-option
  39. v-for="item of bomVersionList"
  40. :key="item.id"
  41. :label="item.name + '(V' + item.versions + '.0)'"
  42. :value="item.id"
  43. ></el-option>
  44. </el-select>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="8">
  48. <el-form-item label="工艺路线:" prop="produceRoutingId">
  49. <!-- @click.native="openVersion" -->
  50. <el-select
  51. v-model="form.produceRoutingId"
  52. style="width: 100%"
  53. @change="changeRoute"
  54. >
  55. <el-option
  56. v-for="item of routingList"
  57. :key="item.id"
  58. :label="item.name"
  59. :value="item.id"
  60. ></el-option>
  61. </el-select>
  62. </el-form-item>
  63. </el-col>
  64. </el-row>
  65. </el-form>
  66. <ele-pro-table
  67. ref="table"
  68. :needPage="false"
  69. :columns="columns"
  70. :datasource="datasource"
  71. @cell-click="cellClick"
  72. row-key="id"
  73. >
  74. <template v-slot:orderNum="{ row }">
  75. {{ row.orderNum }}
  76. </template>
  77. <template v-slot:action="{ row }">
  78. <el-radio class="radio" v-model="radio" :label="row.id"
  79. ><i></i
  80. ></el-radio>
  81. </template>
  82. </ele-pro-table>
  83. <template v-slot:footer>
  84. <el-button type="primary" @click="save"> 确定 </el-button>
  85. <el-button @click="updateVisible(false)"> 返回 </el-button>
  86. </template>
  87. </ele-modal>
  88. </template>
  89. <script>
  90. import { bomListByPlan, bomRoutingList, taskinstanceList } from '@/api/aps';
  91. export default {
  92. components: {},
  93. props: {
  94. // 弹窗是否打开
  95. visible: Boolean
  96. },
  97. data() {
  98. const defaultForm = {
  99. produceType: '',
  100. bomCategoryId: '',
  101. produceRoutingId: ''
  102. };
  103. return {
  104. defaultForm,
  105. radio: null,
  106. current: {},
  107. producedList: [
  108. { code: 2, name: '加工(MBOM)' },
  109. { code: 3, name: '装配(ABOM)' }
  110. ],
  111. index: '',
  112. bomVersionList: [],
  113. routingList: [],
  114. // 表单数据
  115. form: { ...defaultForm },
  116. // 表单验证规则
  117. rules: {},
  118. versionList: [],
  119. // 提交状态
  120. loading: false,
  121. // 是否是修改
  122. isUpdate: false,
  123. columns: [
  124. {
  125. action: 'action',
  126. slot: 'action',
  127. align: 'center',
  128. label: '选择',
  129. width: 80
  130. },
  131. {
  132. prop: 'orderNum',
  133. label: '排序',
  134. align: 'center',
  135. slot: 'orderNum',
  136. width: 80
  137. },
  138. {
  139. prop: 'code',
  140. label: '工序编码',
  141. // sortable: 'custom',
  142. showOverflowTooltip: true,
  143. align: 'center',
  144. minWidth: 110
  145. },
  146. {
  147. prop: 'name',
  148. label: '工序名称',
  149. showOverflowTooltip: true,
  150. align: 'center',
  151. minWidth: 110
  152. },
  153. {
  154. align: 'center',
  155. prop: 'controlName',
  156. label: '工序控制码',
  157. showOverflowTooltip: true,
  158. minWidth: 110
  159. },
  160. {
  161. prop: 'workCenterName',
  162. label: '所属工作中心',
  163. align: 'center',
  164. showOverflowTooltip: true,
  165. minWidth: 110
  166. }
  167. ]
  168. };
  169. },
  170. computed: {
  171. // 是否开启响应式布局
  172. styleResponsive() {
  173. return this.$store.state.theme.styleResponsive;
  174. }
  175. },
  176. methods: {
  177. open(row, index) {
  178. this.data = row;
  179. this.index = index;
  180. },
  181. changeProduceType() {
  182. this.form.bomCategoryId = '';
  183. this.form['bomCategoryName'] = '';
  184. this.form['bomCategoryVersions'] = '';
  185. this.bomVersionList = [];
  186. this.routingList = [];
  187. this.form.produceRoutingId = '';
  188. this.form.produceRoutingName = '';
  189. this.form.produceVersionName = '';
  190. this.bomListVersion();
  191. },
  192. bomListVersion() {
  193. let param = {
  194. bomType: this.form.produceType,
  195. categoryId: this.data.productId
  196. };
  197. bomListByPlan(param).then((res) => {
  198. this.bomVersionList = res || [];
  199. });
  200. },
  201. changeBomId() {
  202. this.routingList = [];
  203. this.form.produceRoutingId = '';
  204. this.form.produceRoutingName = '';
  205. this.form.produceVersionName = '';
  206. this.bomVersionList.forEach((f) => {
  207. if (f.id == this.form.bomCategoryId) {
  208. this.$set(this.form, 'bomCategoryName', f.name);
  209. this.$set(this.form, 'bomCategoryVersions', f.versions);
  210. }
  211. });
  212. this.getPlanRouting();
  213. },
  214. getPlanRouting() {
  215. bomRoutingList(this.form.bomCategoryId).then((res) => {
  216. this.routingList = res || [];
  217. });
  218. },
  219. changeRoute(val) {
  220. if (!val) return;
  221. this.routingList.forEach((f) => {
  222. if (f.id == this.form.produceRoutingId) {
  223. this.$set(this.form, 'produceRoutingName', f.name);
  224. this.$set(this.form, 'produceVersionName', f.version);
  225. }
  226. });
  227. this.$refs.table.reload();
  228. },
  229. /* 表格数据源 */
  230. async datasource() {
  231. if (this.form.produceRoutingId) {
  232. const res = await taskinstanceList({
  233. routingId: this.form.produceRoutingId,
  234. isDetail: true,
  235. pageNum: 1,
  236. size: -1
  237. });
  238. let arr = res.list.map((it) => {
  239. it.detail.orderNum = it.orderNum;
  240. return it.detail;
  241. });
  242. return {
  243. list: arr
  244. };
  245. } else {
  246. return {
  247. list: []
  248. };
  249. }
  250. //this.$refs.table.reload()
  251. },
  252. // 单击获取id
  253. cellClick(row) {
  254. this.current = row;
  255. this.radio = row.id;
  256. },
  257. /* 保存编辑 */
  258. save() {
  259. if (!this.radio) return this.$message.warning('请选择工序');
  260. this.$emit('saveTaskInstance', {
  261. ...this.current,
  262. index: this.index,
  263. produceRoutingId: this.form.produceRoutingId
  264. });
  265. this.updateVisible(false);
  266. },
  267. /* 更新visible */
  268. updateVisible(value) {
  269. this.$emit('update:visible', value);
  270. }
  271. },
  272. watch: {}
  273. };
  274. </script>