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.

index.vue 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div>
  3. <crud-template ref="crudRef" class="as-weight" :submit-state="false" :home-data="field" :tableData="tableData"
  4. @btnSearch="btnSearch" @CurrentChange="handleCurrentChange" @importData="importData" @download="downloadHandle"
  5. @refreshLeft="refreshLeft" @add="Adds" @cancel="cancel" @submit="submitAdd"
  6. @customSelectorSelection="customSelectorSelection" @handleEdit="handleEdit" @handleDelete="deleteHandle">
  7. <template #search>
  8. <el-input maxlength="60" v-trim clearable v-model="searchForm.agencyId" style="width: 200px"
  9. placeholder="请输入渠道编号" />
  10. <el-input maxlength="60" v-trim clearable v-model="searchForm.code" style="width: 200px"
  11. placeholder="请输入仓库编号" />
  12. <el-input maxlength="60" v-trim clearable v-model="searchForm.name" style="width: 200px"
  13. placeholder="请输入仓库名称" />
  14. <el-date-picker unlink-panels v-model="value1" type="daterange" range-separator="到" start-placeholder="开始日期"
  15. end-placeholder="结束日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" @change="dateChangeHandle" style="width: 250px"/>
  16. </template>
  17. <template #operation="{scope}">
  18. <el-button v-if="scope.row.code!=='5201010304001900000'" type="success" size="small" @click="toEdit(scope.row)">修改</el-button>
  19. <el-button type="primary" size="small" @click="showInfo(scope.$index, scope.row)">详情</el-button>
  20. </template>
  21. <template #isCheck="item">
  22. <!-- @vue-ignore -->
  23. <el-switch v-model="item.scope.row.isCheck" :active-value="1" :inactive-value="0" active-color="#13ce66"
  24. inactive-color="#ff4949" @click="handleBeforeChange1(item.scope.row.isCheck, item.scope.row)"></el-switch>
  25. </template>
  26. </crud-template>
  27. <el-dialog title="详情" v-model="dialogVisible">
  28. <el-descriptions direction="vertical" :column="3" border>
  29. <el-descriptions-item class-name="my-content" v-for="item in info" :label="item.label" width="33.3%">
  30. {{ item.value }}
  31. </el-descriptions-item>
  32. </el-descriptions>
  33. </el-dialog>
  34. </div>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref, onMounted, watch, nextTick, toRaw } from 'vue'
  38. // @ts-ignore crudFrom模板
  39. import CrudTemplate from '@/crud/index.vue'
  40. import BaseService from '@/utils/baseService' //引入接口请求
  41. import {
  42. ElMessage,
  43. } from 'element-plus' //提示
  44. import { getZxqdFindConfig } from "./data.js";
  45. import { useRoute } from 'vue-router'
  46. import { exportFn } from '@/views/settlement/exportFn'
  47. //或取路由传入过来的对象数据
  48. const route = useRoute()
  49. const widthBase = '120px';
  50. const crudRef = ref()
  51. const value1 = ref()
  52. let tableData: any = ref([])
  53. const itemStartValue = ref(1)
  54. //查询参数
  55. const searchForm = ref({ agencyId: '' })
  56. const agencyIdList = ref([])
  57. const branchIdList = ref([])
  58. const hallList = ref([])
  59. const upperWarehouseIdList = ref([])
  60. const info = ref({})
  61. const dialogVisible = ref(false)
  62. const field = ref(getZxqdFindConfig(route, agencyIdList, branchIdList, upperWarehouseIdList,hallList));
  63. onMounted(() => {
  64. getList()
  65. getAgenCy()
  66. getUpperWarehouseIdList()
  67. })
  68. function getAgenCy() {
  69. BaseService.post('/userw/agency/agencyqueryall', {}).then((res: any) => {
  70. if (res && res.statusCode === 0) {
  71. //数据转换 .agencyQueryAllModels
  72. let bizContent = res.data
  73. agencyIdList.value = bizContent.map((item) => {
  74. return { label: item.name, value: item.agencyId }
  75. })
  76. // console.log(agencyIdList.value, 'agencyIdList.value')
  77. } else {
  78. ElMessage.error(res.message)
  79. }
  80. })
  81. }
  82. function dateChangeHandle(val: any) {
  83. if (val) {
  84. searchForm.value.insertTimeStart = val[0];
  85. searchForm.value.insertTimeEnd = val[1];
  86. } else {
  87. searchForm.value.insertTimeStart = "";
  88. searchForm.value.insertTimeEnd = "";
  89. }
  90. }
  91. function handleBeforeChange1(value, arg1) {
  92. // console.log(value, arg1);
  93. BaseService.post('/invw/api/warehouse/check', { id: arg1.id, isCheck: value }).then((res: any) => {
  94. if (res && res.statusCode === 0) {
  95. if (value == '1') {
  96. ElMessage.success('库存校验开启')
  97. } else {
  98. ElMessage.error('库存校验关闭')
  99. }
  100. getList()
  101. } else {
  102. ElMessage.error(res.message)
  103. }
  104. })
  105. }
  106. function getUpperWarehouseIdList() {
  107. BaseService.post('/invw/api/warehouse/getWarehouseIdNames', {
  108. "id": "999",
  109. "type": "8"
  110. }).then((res: any) => {
  111. if (res && res.statusCode === 0) {
  112. //数据转换 .agencyQueryAllModels
  113. let bizContent = res.data.idNames
  114. upperWarehouseIdList.value = bizContent.map((item) => {
  115. return { label: item.name, value: item.id }
  116. })
  117. } else {
  118. ElMessage.error(res.message)
  119. }
  120. })
  121. }
  122. //选择变化监听
  123. function customSelectorSelection(value, title, form, item, dialogArray) {
  124. // console.log('value',value, title, form, item, dialogArray);
  125. if (title == 'agencyId') {
  126. if(value !==null && value !== undefined && value!=="") {
  127. BaseService.postN('/userw/serviceHall/serviceHallGetByAgencyId', {agencyId: value}).then((res: any) => {
  128. if (res && res.code === 0) {
  129. let data = res.data || {}
  130. hallList.value = data.map((item) => {
  131. return { label: item.servicehallName, value: item.servicehallId }
  132. })
  133. }
  134. })
  135. }
  136. }
  137. }
  138. // 修改
  139. function toEdit(row) {
  140. const data: any = toRaw(row)
  141. crudRef.value.dialogFormVisible = true
  142. crudRef.value.title = '编辑'
  143. itemStartValue.value = 2
  144. nextTick(() => {
  145. crudRef.value.form={
  146. ...data
  147. }
  148. customSelectorSelection(row.agencyId, 'agencyId',null, null, null)
  149. })
  150. }
  151. //详情
  152. function showInfo(idx: any, row: any) {
  153. let labels = field.value.field
  154. const result: Record<string, any> = {}; // 临时存储结果
  155. // 遍历 labels,提取 label 和对应的 value 剔除labels的isCheck
  156. labels = labels.filter(item => item.prop !== 'isCheck');
  157. labels.forEach((fieldConfig) => {
  158. const { prop, label } = fieldConfig;
  159. result[prop] = {
  160. label: label, // 显示名称
  161. value: row[prop] ?? '--', // 对应 row 的值
  162. };
  163. });
  164. info.value = result; // 更新响应式数据
  165. // console.log('info.value', info.value)
  166. dialogVisible.value = true
  167. }
  168. // 导出
  169. function downloadHandle() {
  170. exportFn('/invw/api/qrySmObuBatch/export', searchForm.value, 'OBU发行批次')
  171. }
  172. //获取列表
  173. function getList() {
  174. crudRef.value.tableLoding = true
  175. let params: any = {
  176. pageNo: field.value.paging.currentPage,
  177. pageSize: field.value.paging.pageSize,
  178. }
  179. //赋值查询参数
  180. let searchFormList = { ...searchForm.value }
  181. for (let key in searchFormList) {
  182. if (searchFormList[key]) {
  183. params[key] = searchFormList[key]
  184. }
  185. }
  186. BaseService.postN('/invw/api/warehouse/page', params).then((res: any) => {
  187. if (res && res.code === 0) {
  188. //数据转换
  189. let bizContent = res.data
  190. let data = bizContent.result || []
  191. //数据渲染
  192. tableData.value = data
  193. crudRef.value.tableLoding = false
  194. //分页总数
  195. field.value.paging.total = bizContent.totalCount
  196. } else {
  197. crudRef.value.tableLoding = false
  198. ElMessage.error(res.message)
  199. }
  200. })
  201. }
  202. const Adds = () => {
  203. itemStartValue.value = 1
  204. }
  205. //表单编辑按钮
  206. function handleEdit(idx: any, row: any) {
  207. itemStartValue.value = 2
  208. }
  209. // 添加
  210. const submitAdd = (data: any) => {
  211. request(data, itemStartValue.value)
  212. }
  213. const request = (data: any, type: any) => {
  214. //操作类型 1新增 2修改
  215. BaseService.postN(type == 1 ? '/invw/api/warehouse/add' : '/invw/api/warehouse/edit', data).then((res: any) => {
  216. if (res && res.code === 0) {
  217. getList()
  218. getAgenCy()
  219. getUpperWarehouseIdList()
  220. crudRef.value.reset();
  221. crudRef.value.dialogFormVisible = false;
  222. }
  223. })
  224. }
  225. // 删除
  226. const deleteHandle = (idx: any, row: any) => {
  227. BaseService.postN('/userw/centerServiceHall/delete', row).then((res: any) => {
  228. if (res && res.code === 0) {
  229. getList()
  230. crudRef.value.reset();
  231. crudRef.value.dialogFormVisible = false;
  232. } else {
  233. ElMessage.error(res.message)
  234. }
  235. })
  236. }
  237. // 搜索按钮
  238. function btnSearch() {
  239. field.value.paging.currentPage = 1
  240. getList()
  241. }
  242. //标签分页
  243. function handleClick(tab, event) {
  244. orderStep.value = tab.props.name
  245. getList()
  246. }
  247. //分页
  248. function handleCurrentChange(val: number) {
  249. field.value.paging.currentPage = val
  250. getList()
  251. }
  252. function handleAvatarSuccess(response: any, row) {
  253. }
  254. // 搜索重置
  255. function refreshLeft() {
  256. searchForm.value = {}
  257. getList()
  258. }
  259. // 获取所有渠道
  260. function getAgencyList() {
  261. }
  262. // 删除
  263. function handleDetele() {
  264. }
  265. // 取消
  266. function cancel() {
  267. }
  268. </script>
  269. <style scoped>
  270. :deep(.my-content){
  271. word-break: break-all;
  272. }
  273. </style>