taskinstanceDialog.vue 7.6 KB

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