基质喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
8.1 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <main class="spurt_print">
  3. <div class="spurt_print_btn ml-[3rem]">
  4. <el-button type="primary" @click='addCraft'>新增工艺</el-button>
  5. <el-button @click="onEdit">编辑</el-button>
  6. <el-button @click="onDel">删除</el-button>
  7. <el-input
  8. class="ml-[20px]"
  9. v-model="searchForm.matrixCraftName"
  10. style="width: 240px"
  11. placeholder="工艺名称"
  12. clearable
  13. />
  14. <el-select
  15. v-model="searchForm.matrixId"
  16. placeholder="选择基质"
  17. no-data-text="无数据"
  18. clearable
  19. style="width: 120px">
  20. <el-option
  21. v-for="item in settingStore.matrixList"
  22. :key="item.id"
  23. :label="item.name"
  24. :value="item.id" />
  25. </el-select>
  26. <el-button @click="getCraftList">搜索</el-button>
  27. </div>
  28. <div class="w-[90vw] ml-[2rem] mt-[2rem] h-[70vh] craft_table">
  29. <el-table empty-text="无数据" :data="tableData" stripe style="width: 100%" ref="craftTableRef" v-loading="loading" >
  30. <el-table-column type="selection" width="55" />
  31. <el-table-column prop="matrixName" label="基质名称" width="100" />
  32. <el-table-column prop="name" label="工艺名称"/>
  33. <el-table-column prop="routeType" label="喷涂路线" width="100">
  34. <template v-slot="scope">
  35. <img v-if="scope.row.routeType === 1" :src="route_h" width="20px" height="20px" alt="icon"/>
  36. <img v-else :src="route_v" width="20px" height="20px" alt="icon"/>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="height" label="喷涂高度" width="100" />
  40. <el-table-column prop="nitrogenFlowVelocity" label="氮气流速" width="100" />
  41. <el-table-column prop="nitrogenAirPressure" label="氮气气压" width="100" />
  42. <el-table-column prop="matrixFlowVelocity" label="基质流速" width="100" />
  43. <el-table-column prop="voltage" label="电压" width="100" />
  44. <el-table-column prop="movementSpeed" label="移速" width="100" />
  45. <el-table-column prop="space" label="行间距" width="100" />
  46. </el-table>
  47. </div>
  48. </main>
  49. <footer class="footer w-[93vw]">
  50. <el-pagination background layout="prev, pager, next" :total="total" />
  51. </footer>
  52. <el-dialog v-model="sprayVisible">
  53. <div>
  54. <div class="mt-[10px]">
  55. <SprayParam :sprayParam='defaultSprayData' @save="onSaveCraft">
  56. <span class="self-center text-right text-primary font-medium">基质名称</span>
  57. <el-select
  58. v-model="defaultSprayData.matrixId"
  59. placeholder="选择"
  60. no-data-text="无数据"
  61. style="width: 120px"
  62. @change="onMatrixChange">
  63. <el-option
  64. v-for="item in settingStore.matrixList"
  65. :key="item.id"
  66. :label="item.name"
  67. :value="item.id" />
  68. </el-select>
  69. <span class="self-center text-right text-primary font-medium"></span>
  70. <span class="self-center text-right text-primary font-medium">工艺名称</span>
  71. <input
  72. type="text"
  73. v-model.number="defaultSprayData.name"
  74. class="border-none outline-none h-[34px] bg-[#E8ECF7] text-primary font-medium rounded-md text-lg text-center" />
  75. <span class="self-center text-right text-primary font-medium"></span>
  76. </SprayParam>
  77. </div>
  78. </div>
  79. </el-dialog>
  80. </template>
  81. <script lang="ts" setup>
  82. import { ref, watch, onMounted } from 'vue'
  83. import { getList, createCraft, updateCraft, delCraft} from '@/services/matrix/craft'
  84. import { useSettingStore } from '@/stores/setting'
  85. import SprayParam from '@/components/SprayParam.vue'
  86. import type { CraftItem } from "@/services/matrix/type";
  87. import type { WorkType } from "@/services/globalCmd/cmdTypes";
  88. import { ElMessage, ElMessageBox } from "element-plus";
  89. import route_h from "@/assets/route_horizontal.png";
  90. import route_v from "@/assets/route_vertical.png";
  91. import type { MatrixItem } from '../matrixManage/type';
  92. let total = ref(0)
  93. const settingStore = useSettingStore()
  94. let sprayVisible = ref(false)
  95. let tableData = ref<MatrixItem[]>([])
  96. let operType = ref('add')
  97. let loading = ref(false)
  98. const searchForm = ref({
  99. matrixCraftName:undefined,
  100. matrixId:undefined,
  101. })
  102. const defaultCraft: CraftItem = {
  103. id: 1,
  104. name: '',
  105. matrixId: 0,
  106. routeType: 1,
  107. space: 0,
  108. nitrogenFlowVelocity: 0,
  109. nitrogenAirPressure: 0,
  110. matrixFlowVelocity: 0,
  111. voltage: 0,
  112. needPower: false,
  113. height: 0,
  114. movementSpeed: 0,
  115. position: [],
  116. };
  117. const defaultSprayData = ref<CraftItem>(defaultCraft);
  118. watch(()=>settingStore.matrixList, (newVal)=>{
  119. if(newVal && newVal.length){
  120. onMatrixChange(newVal[0].id)
  121. }else{
  122. onMatrixChange(null)
  123. }
  124. })
  125. onMounted(()=>{
  126. let matrixList = settingStore.matrixList
  127. if(matrixList && matrixList.length){
  128. onMatrixChange(matrixList[0].id)
  129. }else{
  130. onMatrixChange(null)
  131. }
  132. getCraftList()
  133. })
  134. //工艺列表
  135. const getCraftList = () => {
  136. const params = {
  137. pageNum:1,
  138. pageSize:10,
  139. ...searchForm.value
  140. }
  141. loading.value = true;
  142. getList(params).then((res)=>{
  143. let list = res.data.list
  144. settingStore.setMatrixCraftList(list)
  145. tableData.value = list
  146. total.value = res.data.total
  147. }).finally(()=>{
  148. loading.value = false;
  149. })
  150. }
  151. const addCraft = () => {
  152. sprayVisible.value = true;
  153. operType.value = 'add'
  154. }
  155. const craftTableRef = ref()
  156. const onEdit = () => {
  157. const selectRows = craftTableRef.value.getSelectionRows()
  158. if(selectRows.length !== 1){
  159. ElMessage.error('请选择一条数据进行编辑')
  160. return;
  161. }
  162. const sel = selectRows[0]
  163. operType.value = 'edit'
  164. defaultSprayData.value = sel
  165. sprayVisible.value = true;
  166. }
  167. const onDel = () => {
  168. const selectRows = craftTableRef.value.getSelectionRows() as CraftItem[]
  169. if(!selectRows.length){
  170. ElMessage.error('请选择要删除的数据')
  171. return;
  172. }
  173. const ids = selectRows.map(item => item.id)
  174. ElMessageBox.confirm('确认删除此条数据吗?','提示',{
  175. confirmButtonText: '确认',
  176. cancelButtonText: '取消',
  177. type: 'warning',
  178. }).then(()=>{
  179. delCraft(ids.join(',')).then(res => {
  180. if(res.success){
  181. ElMessage.success("删除成功")
  182. getCraftList()
  183. }else{
  184. ElMessage.error(res.msg)
  185. }
  186. })
  187. })
  188. }
  189. const onSaveCraft = (craftData:WorkType) => {
  190. //校验必填
  191. const {
  192. routeType,
  193. space,
  194. nitrogenFlowVelocity,
  195. nitrogenAirPressure,
  196. matrixFlowVelocity,
  197. voltage,
  198. height,
  199. movementSpeed,
  200. position,
  201. } = craftData;
  202. if(!defaultSprayData.value.matrixId){
  203. ElMessage.error('请选择基质名称')
  204. return;
  205. }
  206. if(!defaultSprayData.value.name){
  207. ElMessage.error('请输入工艺名称')
  208. return;
  209. }
  210. if(!routeType){
  211. ElMessage.error('请选择喷涂 ')
  212. return;
  213. }
  214. if(!movementSpeed){
  215. ElMessage.error('请输入移动速度 ')
  216. return;
  217. }
  218. if(operType.value === 'add'){
  219. //@ts-ignore
  220. createCraft(craftData).then(res=>{
  221. if(res.success){
  222. ElMessage.success('新增成功')
  223. getCraftList()
  224. sprayVisible.value = false;
  225. }
  226. })
  227. }else if(operType.value === 'edit'){
  228. //@ts-ignore
  229. updateCraft(craftData).then(res=>{
  230. if(res.success){
  231. ElMessage.success('编辑成功')
  232. getCraftList()
  233. sprayVisible.value = false;
  234. }
  235. })
  236. }
  237. }
  238. function onMatrixChange(val:number|null) {
  239. defaultSprayData.value.matrixId = val
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. .el-button--primary{
  244. background: linear-gradient(90deg, #0657c0 24%, #096ae0 101%);;
  245. }
  246. .spurt_print{
  247. height: 75vh;
  248. .spurt_print_btn{
  249. margin-top: 2rem;
  250. }
  251. }
  252. .footer{
  253. display: flex;
  254. justify-content: end;
  255. position: relative;
  256. .pagination{
  257. position: absolute;
  258. bottom: 0;
  259. right: 3rem;
  260. }
  261. }
  262. .craft_table{
  263. height: 65vh;
  264. background: #ffffff;
  265. }
  266. </style>