index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="page-container row-container">
  3. <!-- 左侧区域 -->
  4. <section class="list-part-container" style="flex: 2">
  5. <!-- 搜索区 -->
  6. <el-form class="list-search-container" :model="queryDeptParams" ref="queryRef" :inline="true">
  7. <el-form-item class="section-title" label="车间管理" />
  8. <el-form-item>
  9. <el-button v-hasPermi="['business:workshop:add']" type="primary" icon="Plus" @click="handleAdd">新增</el-button>
  10. </el-form-item>
  11. <el-form-item label="车间名称:" prop="name">
  12. <el-input v-model.trim="queryParams.name" placeholder="请输入车间名称" @keydown.enter.prevent
  13. @keyup.enter="handleSearch" clearable style="width: 155px" />
  14. </el-form-item>
  15. <el-form-item>
  16. <el-button type="info" icon="Search" @click="handleSearch">搜索</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <!-- 列表区 -->
  20. <div class="el-table-container">
  21. <div class="el-table-inner-container">
  22. <!-- 列表区 -->
  23. <el-table ref="workshopTable" v-loading="loading" :data="workshopList" row-key="id" height="100%" :indent="20"
  24. default-expand-all highlight-current-row @current-change="handleGetDept">
  25. <el-table-column label="行号" type="index" width="50" align="center" />
  26. <el-table-column label="车间名称" prop="name" align="center" />
  27. <el-table-column label="操作" width="150" align="center">
  28. <template #default="scope">
  29. <el-button v-hasPermi="['business:workshop:edit']" link type="warning" icon="Edit"
  30. @click="handleUpdateWorkshop(scope.row)">编辑</el-button>
  31. <el-button v-hasPermi="['business:workshop:remove']" link type="danger" icon="Delete"
  32. @click="handleDeleteWorkshop(scope.row)">删除</el-button>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. </div>
  38. </section>
  39. <!-- 右侧区域 -->
  40. <section class="list-part-container column-container" style="flex: 3">
  41. <!-- 工段 -->
  42. <section class="list-part-container column-container" style="flex: 1">
  43. <!-- 搜索区 -->
  44. <el-form class="list-search-container" :model="queryDeptParams" ref="queryRef" :inline="true">
  45. <el-form-item class="section-title" label="工段" />
  46. <el-form-item>
  47. <el-button v-hasPermi="['business:workshop:add']" type="primary" icon="Plus"
  48. :disabled="workshopList.length == 0" @click="handleAddDept">新增</el-button>
  49. <el-button v-hasPermi="['business:workshop:remove']" type="danger" icon="Delete" :disabled="ids.length == 0"
  50. @click="handleDeptDelete"> 删除</el-button>
  51. </el-form-item>
  52. </el-form>
  53. <!-- 列表区 -->
  54. <div class="el-table-container">
  55. <div class="el-table-inner-container">
  56. <el-table v-loading="deptLoading" :data="deptList" :row-key="getRowKey" height="100%"
  57. @selection-change="handleSelectionChange">
  58. <el-table-column type="selection" width="40" align="center" />
  59. <el-table-column type="index" label="行号" width="50" align="center" />
  60. <el-table-column label="工段名称" prop="deptName" align="center" />
  61. <el-table-column label="工段编码" prop="deptCode" align="center" />
  62. </el-table>
  63. </div>
  64. </div>
  65. <!-- 分页 -->
  66. <pagination v-show="total > 0" :total="total" v-model:page="queryDeptParams.pageNum"
  67. v-model:limit="queryDeptParams.pageSize" @pagination="getDeptList" />
  68. </section>
  69. <!-- 周转区 -->
  70. <section class="list-part-container column-container" style="flex: 1">
  71. <!-- 搜索区 -->
  72. <el-form class="list-search-container" :model="queryDeptParams" ref="queryRef" :inline="true">
  73. <el-form-item class="section-title" label="周转区" />
  74. <el-form-item>
  75. <el-button v-hasPermi="['business:workshop:add']" type="primary" icon="Plus"
  76. @click="handleShowTurnoverFormDialog(null)">新增</el-button>
  77. </el-form-item>
  78. </el-form>
  79. <!-- 列表区 -->
  80. <div class="el-table-container">
  81. <div class="el-table-inner-container">
  82. <el-table v-loading="turnoverLoading" :data="turnoverList" height="100%">
  83. <el-table-column type="index" label="行号" width="50" align="center" />
  84. <el-table-column label="周转区名称" prop="code" width="160" align="center" />
  85. <el-table-column label="状态" width="80" prop="status" align="center">
  86. <template #default="scope">
  87. <dict-tag :options="turnover_status" :value="scope.row.status" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="备注" prop="remark" align="center" />
  91. <el-table-column label="操作" width="150" align="center">
  92. <template #default="scope">
  93. <el-button v-hasPermi="['business:workshop:edit']" link type="warning" icon="Edit"
  94. @click="handleShowTurnoverFormDialog(scope.row.id)"> 编辑
  95. </el-button>
  96. <el-button v-hasPermi="['business:workshop:remove']" link type="danger" icon="Delete"
  97. @click="handleDeleteTurnover(scope.row)"> 删除 </el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. </div>
  102. </div>
  103. </section>
  104. </section>
  105. <!-- 车间管理表单 -->
  106. <workshop-form ref="workshopRef" @handleSaveSuccess="getList" />
  107. <!-- 工段弹窗 -->
  108. <dept-form ref="deptChoiceRef" :multiple="true" :multiple-selected="handleDeptSelected" />
  109. <!-- 周转区弹窗 -->
  110. <turnover-form ref="turnoverRef" @handleSaveSuccess="handleRefreshTurnover" />
  111. </div>
  112. </template>
  113. <script setup>
  114. import { listWorkshop, delWorkshop } from '@/api/business/workshop'
  115. import { listDept, updateDeptWorkshop, updateDeptWorkshopByDeptId } from '@/api/system/dept'
  116. import { listTurnover, delTurnover } from '@/api/business/workshopTurnover'
  117. import deptForm from '@/views/business/workshop/DialogDept'
  118. import turnoverForm from '@/views/business/workshop/DialogFormTurnover'
  119. import workshopForm from './form'
  120. const { proxy } = getCurrentInstance()
  121. /** 字典数组区 */
  122. const { turnover_status } = proxy.useDict('turnover_status')
  123. /** 车间管理变量 */
  124. const workshopList = ref([])
  125. const loading = ref(false)
  126. const currentWorkshop = ref({})
  127. /** 工段变量 */
  128. const deptList = ref([])
  129. const deptLoading = ref(false)
  130. const total = ref(0)
  131. const ids = ref([])
  132. /** 周转区 */
  133. const turnoverList = ref([])
  134. const turnoverLoading = ref(false)
  135. /** 查询对象 */
  136. const queryParams = ref({
  137. name: ''
  138. })
  139. const queryDeptParams = ref({
  140. pageSize: 10,
  141. pageNum: 1,
  142. deptCode: ''
  143. })
  144. /*********************** 方法区 ****************************/
  145. /*********************** 车间管理事件 ****************************/
  146. /** 查询车间管理列表 */
  147. function getList() {
  148. loading.value = true
  149. currentWorkshop.value = {}
  150. listWorkshop(queryParams.value).then((res) => {
  151. if (res.code == 200) {
  152. workshopList.value = res.rows
  153. loading.value = false
  154. if (workshopList.value.length > 0) {
  155. currentWorkshop.value = workshopList.value[0]
  156. proxy.$refs.workshopTable.setCurrentRow(workshopList.value[0])
  157. } else {
  158. deptList.value = []
  159. total.value = 0
  160. }
  161. }
  162. })
  163. }
  164. /**车间查询 */
  165. function handleSearch() {
  166. getList()
  167. }
  168. /** 车间新增按钮操作 */
  169. function handleAdd() {
  170. proxy.$refs.workshopRef.open()
  171. }
  172. /** 修改按钮操作 */
  173. function handleUpdateWorkshop(row) {
  174. proxy.$refs.workshopRef.open(row)
  175. }
  176. /**车间表点击事件 */
  177. function handleGetDept(row) {
  178. if (row) {
  179. currentWorkshop.value = row
  180. }
  181. // 获取工段
  182. getDeptList()
  183. // 获取周转区
  184. getTurnovers()
  185. }
  186. /** 车间删除按钮操作 */
  187. function handleDeleteWorkshop(row) {
  188. const _ids = row.id
  189. proxy.$modal
  190. .confirm('是否确认删除选中的车间?')
  191. .then(function () {
  192. return delWorkshop(_ids)
  193. })
  194. //删除车间的同时删除工段上workId
  195. .then(function () {
  196. return updateDeptWorkshopByDeptId({ workshopId: _ids })
  197. })
  198. .then(() => {
  199. getList()
  200. proxy.$modal.msgSuccess('删除成功!')
  201. })
  202. .catch(() => { })
  203. }
  204. /*********************** 工段相关事件 ****************************/
  205. //打开添加工段
  206. const handleAddDept = () => {
  207. handleAddBatchDept()
  208. }
  209. /** 多选添加 */
  210. function handleAddBatchDept() {
  211. let deptIds = []
  212. deptIds = deptList.value.map((item) => {
  213. return item.deptId
  214. })
  215. proxy.$refs.deptChoiceRef.open(deptIds)
  216. }
  217. // 工段多选框选中数据
  218. function handleSelectionChange(selection) {
  219. ids.value = selection.map((item) => {
  220. return item.deptId
  221. })
  222. }
  223. /** 获取行 id */
  224. function getRowKey(row) {
  225. return row.deptId
  226. }
  227. //工段多选带回
  228. function handleDeptSelected(selection) {
  229. let deptInfo = {}
  230. let deptIds = []
  231. deptIds = selection.map((item) => {
  232. return item.deptId
  233. })
  234. deptInfo.workshopId = currentWorkshop.value.id
  235. deptInfo.ids = deptIds
  236. updateDeptWorkshop(deptInfo).then((res) => {
  237. if (res.code == 200) {
  238. handleGetDept(currentWorkshop.value)
  239. proxy.$modal.msgSuccess('添加成功!')
  240. }
  241. })
  242. }
  243. /**获得工段列表 */
  244. function getDeptList() {
  245. deptLoading.value = true
  246. queryDeptParams.value.workshopId = currentWorkshop.value.id
  247. if (currentWorkshop.value.id) {
  248. listDept(queryDeptParams.value).then((res) => {
  249. if (res.code == 200) {
  250. deptList.value = res.rows
  251. total.value = res.total
  252. }
  253. })
  254. }
  255. deptLoading.value = false
  256. }
  257. /** 车间工段删除按钮操作 */
  258. function handleDeptDelete() {
  259. proxy.$modal.confirm('是否确认删除选中的车间?').then(function () {
  260. updateDeptWorkshop({ ids: ids.value }).then((res) => {
  261. if (res.code == 200) {
  262. handleGetDept(currentWorkshop.value)
  263. proxy.$modal.msgSuccess('删除成功!')
  264. }
  265. })
  266. })
  267. }
  268. /********************************************** 周转区相关事件 **********************************************/
  269. /** 刷新周转区事件 */
  270. const handleRefreshTurnover = () => {
  271. getTurnovers()
  272. }
  273. //获得周转位置
  274. const getTurnovers = () => {
  275. turnoverLoading.value = true
  276. listTurnover({ workshopId: currentWorkshop.value.id ?? '0' }).then((res) => {
  277. turnoverList.value = res.data
  278. turnoverLoading.value = false
  279. })
  280. }
  281. /** 打开周转区对话框事件 */
  282. const handleShowTurnoverFormDialog = (id) => {
  283. proxy.$refs.turnoverRef.open({
  284. workshopId: currentWorkshop.value.id,
  285. id: id
  286. })
  287. }
  288. /** 删除周转区事件 */
  289. function handleDeleteTurnover(row) {
  290. proxy.$modal
  291. .confirm('确定删除选中项?')
  292. .then(() => {
  293. return delTurnover(row.id)
  294. })
  295. .then(() => {
  296. getTurnovers()
  297. proxy.$modal.msgSuccess('删除成功!')
  298. })
  299. .catch(() => { })
  300. }
  301. onMounted(() => {
  302. getList()
  303. })
  304. </script>