基质喷涂
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.

276 lines
7.8 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
  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_h" 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">
  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. style="width: 120px"
  61. @change="onMatrixChange">
  62. <el-option
  63. v-for="item in settingStore.matrixList"
  64. :key="item.id"
  65. :label="item.name"
  66. :value="item.id" />
  67. </el-select>
  68. <span class="self-center text-right text-primary font-medium"></span>
  69. <span class="self-center text-right text-primary font-medium">工艺名称</span>
  70. <input
  71. type="text"
  72. v-model.number="defaultSprayData.name"
  73. class="border-none outline-none h-[34px] bg-[#E8ECF7] text-primary font-medium rounded-md text-lg text-center" />
  74. <span class="self-center text-right text-primary font-medium"></span>
  75. </SprayParam>
  76. </div>
  77. </div>
  78. </el-dialog>
  79. </template>
  80. <script lang="ts" setup>
  81. import { ref, watch, onMounted } from 'vue'
  82. import { getList, createCraft, updateCraft, delCraft} from '@/services/matrix/craft'
  83. import { useSettingStore } from '@/stores/setting'
  84. import SprayParam from '@/components/SprayParam.vue'
  85. import type { CraftItem } from "@/services/matrix/type";
  86. import type { WorkType } from "@/services/globalCmd/cmdTypes";
  87. import { ElMessage, ElMessageBox } from "element-plus";
  88. import route_h from "@/assets/route_horizontal.png";
  89. let total = ref()
  90. const settingStore = useSettingStore()
  91. let sprayVisible = ref(false)
  92. let tableData = ref<any>([])
  93. let operType = ref('add')
  94. let loading = ref(false)
  95. const searchForm = ref({
  96. matrixCraftName:undefined,
  97. matrixId:undefined,
  98. })
  99. const defaultCraft: CraftItem = {
  100. id: 1,
  101. name: '',
  102. matrixId: 0,
  103. routeType: 1,
  104. space: 0,
  105. nitrogenFlowVelocity: 0,
  106. nitrogenAirPressure: 0,
  107. matrixFlowVelocity: 0,
  108. voltage: 0,
  109. needPower: false,
  110. height: 0,
  111. movementSpeed: 0,
  112. position: [],
  113. };
  114. const defaultSprayData = ref<CraftItem>(defaultCraft);
  115. watch(()=>settingStore.matrixList, (newVal)=>{
  116. if(newVal && newVal.length){
  117. defaultSprayData.value.matrixId = newVal[0].id
  118. }
  119. })
  120. onMounted(()=>{
  121. tableData.value = settingStore.matrixList;
  122. getCraftList()
  123. })
  124. //工艺列表
  125. const getCraftList = () => {
  126. const params = {
  127. pageNum:1,
  128. pageSize:10,
  129. ...searchForm.value
  130. }
  131. loading.value = true;
  132. getList(params).then((res:any)=>{
  133. tableData.value = res.data.list
  134. total.value = res.data.total
  135. }).finally(()=>{
  136. loading.value = false;
  137. })
  138. }
  139. const addCraft = () => {
  140. sprayVisible.value = true;
  141. operType.value = 'add'
  142. }
  143. const craftTableRef = ref()
  144. const onEdit = () => {
  145. const selectRows = craftTableRef.value.getSelectionRows()
  146. if(selectRows.length !== 1){
  147. ElMessage.error('请选择一条数据进行编辑')
  148. return;
  149. }
  150. const sel = selectRows[0]
  151. operType.value = 'edit'
  152. defaultSprayData.value = sel
  153. sprayVisible.value = true;
  154. }
  155. const onDel = () => {
  156. const selectRows = craftTableRef.value.getSelectionRows()
  157. if(!selectRows.length){
  158. ElMessage.error('请选择要删除的数据')
  159. return;
  160. }
  161. const ids = selectRows.map((item:any) => item.id)
  162. ElMessageBox.confirm('确认删除此条数据吗?','提示',{
  163. confirmButtonText: '确认',
  164. cancelButtonText: '取消',
  165. type: 'warning',
  166. }).then(()=>{
  167. delCraft(ids.join(',')).then(res => {
  168. if(res.success){
  169. ElMessage.success("删除成功")
  170. getCraftList()
  171. }else{
  172. ElMessage.error(res.msg)
  173. }
  174. })
  175. })
  176. }
  177. const onSaveCraft = (craftData:WorkType) => {
  178. //校验必填
  179. const {
  180. routeType,
  181. space,
  182. nitrogenFlowVelocity,
  183. nitrogenAirPressure,
  184. matrixFlowVelocity,
  185. voltage,
  186. height,
  187. movementSpeed,
  188. position,
  189. } = craftData;
  190. if(!defaultSprayData.value.matrixId){
  191. ElMessage.error('请选择基质名称')
  192. return;
  193. }
  194. if(!defaultSprayData.value.name){
  195. ElMessage.error('请输入工艺名称')
  196. return;
  197. }
  198. if(!routeType){
  199. ElMessage.error('请选择喷涂 ')
  200. return;
  201. }
  202. if(!movementSpeed){
  203. ElMessage.error('请输入移动速度 ')
  204. return;
  205. }
  206. if(operType.value === 'add'){
  207. //@ts-ignore
  208. createCraft(craftData).then(res=>{
  209. if(res.success){
  210. ElMessage.success('新增成功')
  211. getCraftList()
  212. sprayVisible.value = false;
  213. }
  214. })
  215. }else if(operType.value === 'edit'){
  216. //@ts-ignore
  217. updateCraft(craftData).then(res=>{
  218. if(res.success){
  219. ElMessage.success('编辑成功')
  220. getCraftList()
  221. sprayVisible.value = false;
  222. }
  223. })
  224. }
  225. }
  226. function onMatrixChange(val: number) {
  227. defaultSprayData.value.matrixId = val
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .el-button--primary{
  232. background: linear-gradient(90deg, #0657c0 24%, #096ae0 101%);;
  233. }
  234. .spurt_print{
  235. height: 75vh;
  236. .spurt_print_btn{
  237. margin-top: 2rem;
  238. }
  239. }
  240. .footer{
  241. display: flex;
  242. justify-content: end;
  243. position: relative;
  244. .pagination{
  245. position: absolute;
  246. bottom: 0;
  247. right: 3rem;
  248. }
  249. }
  250. .craft_table{
  251. height: 65vh;
  252. background: #ffffff;
  253. }
  254. </style>