index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" hide-no-more-inside>
  3. <template #top>
  4. <ut-navbar title="产地加工" :fixed="false"> </ut-navbar>
  5. </template>
  6. <template>
  7. <view class="d-flex a-c pd-24 pb-0 bg-#f7f7f7">
  8. <view class="min-w-220 flex1">
  9. <ut-action-sheet v-model="form.processType" :tabs="[{ label: '全部', value: '' }, ...pt_process_type]" @change="onRefresh" title="选择原料类型">
  10. <view class="d-flex search-select-item a-c">
  11. <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no d-flex a-c j-c">
  12. <view class="w-s-no">{{ selectDictLabel(pt_process_type, form.processType) || '全部' }}</view>
  13. <template v-for="(item, index) in processCountList" :key="index">
  14. <view class="" v-if="form.processType == item?.type">({{ item?.num }})</view>
  15. </template>
  16. </view>
  17. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
  18. </view>
  19. </ut-action-sheet>
  20. </view>
  21. <view class="h-86 pl-20 w-100%">
  22. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" @change="changeSeach" margin="0" :border="false" placeholder="搜药材名、批号" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  23. </view>
  24. </view>
  25. <view class="pd-24">
  26. <up-swipe-action>
  27. <up-swipe-action-item v-for="(item, index) in list" :key="index" :name="item?.id" :options="swipeOptions" class="mb-16" @click="handleSwipeClick">
  28. <template #default>
  29. <view class="bg-#fff b-radius pd-24 p-rtv">
  30. <view v-if="+item?.processType == 1 && +item?.processMedType == 1" class="bg-#91C747 c-#fff f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 16rpx 0 16rpx 0; width: max-content; position: absolute; top: 0rpx; left: 0rpx">种子初加工</view>
  31. <view v-if="+item?.processType == 1 && +item?.processMedType == 2" class="bg-#C7A262 c-#fff f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 16rpx 0 16rpx 0; width: max-content; position: absolute; top: 0rpx; left: 0rpx">药材初加工</view>
  32. <view v-if="+item?.processType == 2" class="bg-#37A954 c-#fff f-w-5 pd-10 pt-4 pb-4 f-s-20" style="border-radius: 16rpx 0 16rpx 0; width: max-content; position: absolute; top: 0rpx; left: 0rpx">趁鲜切制</view>
  33. <view v-if="item?.processingDate || item?.processingDateEnd" class="d-flex a-c j-ed">
  34. <view class="c-#999 f-s-24">{{ item?.processingDate }} 至 {{ item?.processingDateEnd }}</view>
  35. </view>
  36. <view class="" @click="gotodetaillist(item)">
  37. <view class="mb-10 d-flex a-c">
  38. <view class="">
  39. <span v-if="item?.variety" class="f-s-34 c-#333 f-w-500 mr-10">{{ item?.variety }}</span>
  40. <span v-else class="f-s-34 c-#333 f-w-500 mr-10">{{ item?.medicineName }}(鲜制)</span>
  41. <span class="f-s-24 c-#666" v-if="+item?.processMedType == 1">{{ selectDictLabel(pt_stock_type, item?.processMedType) }}</span>
  42. </view>
  43. <view class="flex1"></view>
  44. <up-icon name="arrow-right" size="26rpx"></up-icon>
  45. </view>
  46. <view class="pd2-4-0 f-s-28">
  47. <span class="c-#666">加工批号:</span>
  48. <span class="c-#333 f-w-500">{{ item?.processCode }}</span>
  49. </view>
  50. <view v-if="+item?.processType == 1" class="pd2-4-0 f-s-28">
  51. <span class="c-#666">执行标准:</span>
  52. <span class="c-#333 f-w-500">{{ selectDictLabel(pt_standard_type, item?.standardType) }}</span>
  53. <span class="c-#666" v-if="item?.standardDetailName">({{ item?.standardDetailName }})</span>
  54. </view>
  55. <view v-else class="pd2-4-0 f-s-28">
  56. <span class="c-#666">执行标准:</span>
  57. <span class="c-#666" v-if="item?.standardDetailName">{{ item?.standardDetailName }}</span>
  58. </view>
  59. <view class="pd2-4-0 f-s-28">
  60. <span class="c-#666">加工工艺:</span>
  61. <template v-for="(items, indexs) in item?.ptech?.split(',')" v-if="item?.ptech" :key="indexs">
  62. <span v-if="indexs !== 0" class="c-#999 f-s-32 ml-10 mr-10">→ </span>
  63. <span class="f-s-32">{{ items }}</span>
  64. </template>
  65. <template v-else>
  66. <span class="c-#999 f-s-32">-</span>
  67. </template>
  68. </view>
  69. <view class="pd2-4-0 f-s-28">
  70. <span class="c-#666">加工负责人:</span>
  71. <span class="c-#333 f-w-500">{{ item?.contactName }}</span>
  72. </view>
  73. </view>
  74. <Output :data="item" />
  75. </view>
  76. </template>
  77. </up-swipe-action-item>
  78. </up-swipe-action>
  79. </view>
  80. </template>
  81. <template #empty>
  82. <view class="d-flex flex-cln a-c">
  83. <ut-empty class="mg-at" color="#ccc" size="28rpx" image="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images-plt/plant/noEmptyBase.png">暂无加工任务</ut-empty>
  84. <text class="c-#ccc f-s-28">点击下方按钮去添加吧~</text>
  85. </view>
  86. </template>
  87. <template #bottom>
  88. <ut-tabar activeTab="processing"></ut-tabar>
  89. </template>
  90. </z-paging>
  91. <ut-suspension v-if="sus?.left" :imageWidth="60" :imageHeight="60" :x="sus?.left" :y="sus?.bottom" :inertia="false" :snap-threshold="40">
  92. <image src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images-plt/common/btn_add_logo.png" mode="widthFix" class="w-120 h-120" @click="showDeleteDialog = true"></image>
  93. </ut-suspension>
  94. <ut-confirm-dialog v-model:show="showDeleteDialog" width="80vw" title="请选择要创建的任务类型" :confirmText="'确认选择'" :cancelText="'取消'" @confirm="handlechoseConfirm" @cancel="handleDeleteCancel">
  95. <view class="" v-for="item in pt_process_type" :key="item?.value">
  96. <view style="border: 1rpx solid" :style="{ backgroundColor: item?.value == basetype ? '#EBF6EE' : '#f7f7f7', borderColor: item?.value == basetype ? '#37A954' : 'transparent' }" class="pr-30 d-flex a-c mb-20 radius-100" @click="handlechose(item.value)">
  97. <view class="radius-50% mg-8 bg-#F0F0F0" v-if="item?.value == '1'">
  98. <up-avatar size="90rpx" src="/static/images/plant/processing/processType_initial.png"></up-avatar>
  99. </view>
  100. <view class="radius-50% mg-8 bg-#F0F0F0" v-if="item?.value == '2'">
  101. <up-avatar size="90rpx" src="/static/images/plant/processing/processType_fresh.png"></up-avatar>
  102. </view>
  103. <view class="c-#333 f-s-34">
  104. {{ item?.label }}
  105. </view>
  106. <view class="flex1"></view>
  107. <view class="d-flex">
  108. <img v-if="basetype === item.value" class="w-30 h-30" src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images-plt/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
  109. </view>
  110. </view>
  111. </view>
  112. </ut-confirm-dialog>
  113. </template>
  114. <script setup lang="ts">
  115. import { useClientRequest } from '@/utils/request';
  116. import Output from './models/output.vue';
  117. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  118. const { pt_process_type, pt_stock_type, pt_standard_type } = toRefs<any>(proxy?.useDict('pt_process_type', 'pt_stock_type', 'pt_standard_type'));
  119. const sus = ref({
  120. left: 0,
  121. bottom: 0,
  122. });
  123. const systemInfo = uni.getSystemInfoSync();
  124. const windowInfo = uni.getWindowInfo();
  125. const safeAreaBottom = windowInfo.safeAreaInsets.bottom;
  126. sus.value.left = systemInfo.windowWidth - 10;
  127. sus.value.bottom = systemInfo.windowHeight - 200;
  128. const showDeleteDialog = ref(false);
  129. const basetype = ref();
  130. const processCountList = ref<any>();
  131. const handlechose = (item: string) => {
  132. basetype.value = item;
  133. };
  134. // 处理取消
  135. const handleDeleteCancel = () => {
  136. showDeleteDialog.value = false;
  137. basetype.value = '';
  138. };
  139. const handlechoseConfirm = () => {
  140. if (!basetype.value) {
  141. uni.showToast({
  142. title: '请选择要创建的任务类型',
  143. icon: 'none',
  144. duration: 2000,
  145. });
  146. return;
  147. }
  148. uni.$u.route({ type: 'navigateTo', url: '/plant/processing/processing-create/index', params: { processType: basetype.value } });
  149. };
  150. const paging = ref();
  151. const list = ref<any[]>([]);
  152. const tabs = [
  153. {
  154. label: '加工',
  155. value: '0',
  156. },
  157. {
  158. label: '包装赋码',
  159. value: '1',
  160. },
  161. ];
  162. const form = ref({
  163. storageType: '4',
  164. processType: '',
  165. keyword: '',
  166. });
  167. // 滑动操作选项
  168. const swipeOptions = reactive([
  169. {
  170. text: '复制',
  171. style: {
  172. backgroundColor: '#37A954',
  173. width: '80rpx',
  174. fontSize: '28rpx',
  175. },
  176. },
  177. {
  178. text: '修改',
  179. style: {
  180. backgroundColor: '#18BECA',
  181. width: '80rpx',
  182. fontSize: '28rpx',
  183. },
  184. },
  185. {
  186. text: '删除',
  187. style: {
  188. backgroundColor: '#F74C30',
  189. width: '80rpx',
  190. fontSize: '28rpx',
  191. },
  192. },
  193. ]);
  194. // 处理滑动按钮点击
  195. const handleSwipeClick = async (event: any) => {
  196. const { name, index } = event;
  197. const item = list.value[index];
  198. if (index === 0) {
  199. // 点击复制
  200. handleCopy(name, item);
  201. } else if (index === 1) {
  202. // 点击修改
  203. handleEdit(item);
  204. } else if (index === 2) {
  205. // 点击删除
  206. handleDelete(name, item);
  207. }
  208. };
  209. // 处理复制
  210. const handleCopy = async (processId: string | number, item: any) => {
  211. try {
  212. const res = await uni.showModal({
  213. title: '复制提示',
  214. content: '确定复制该加工任务吗?',
  215. confirmColor: '#37A954',
  216. });
  217. if (!res.confirm) return;
  218. const copyRes = await useClientRequest.get(`/plt-api/app/processe/copyProcess/${processId}`);
  219. if (copyRes && copyRes.code === 200) {
  220. uni.showToast({ title: '复制成功', icon: 'success' });
  221. paging.value?.reload();
  222. }
  223. } catch (error) {
  224. console.error('复制失败:', error);
  225. }
  226. };
  227. // 处理修改
  228. const handleEdit = (item: any) => {
  229. uni.$u.route({
  230. type: 'navigateTo',
  231. url: '/plant/processing/processing-create/index',
  232. params: { id: item?.id, edit: 1 },
  233. });
  234. };
  235. // 处理删除
  236. const handleDelete = async (processId: string | number, item: any) => {
  237. try {
  238. const res = await uni.showModal({
  239. title: '删除提示',
  240. content: '删除后不可恢复,请谨慎操作!',
  241. confirmColor: '#F74C30',
  242. });
  243. if (!res.confirm) return;
  244. const delRes = await useClientRequest.get(`/plt-api/app/processe/deleteProcess/${processId}`);
  245. if (delRes && delRes.code === 200) {
  246. uni.showToast({ title: '删除成功', icon: 'none' });
  247. paging.value?.reload();
  248. }
  249. } catch (error) {
  250. console.error('删除失败:', error);
  251. }
  252. };
  253. const changeSeach = () => {
  254. paging.value.reload();
  255. };
  256. const query = async (pageNum: number, pageSize: number) => {
  257. const params = {
  258. pageNum,
  259. pageSize,
  260. ...form.value,
  261. };
  262. const res = await useClientRequest.get('/plt-api/app/processe/pageList', params);
  263. if (res) {
  264. const { rows } = res;
  265. paging.value.complete(rows);
  266. }
  267. };
  268. const gotodetaillist = (item: any) => {
  269. uni.$u.route({
  270. type: 'navigateTo',
  271. url: '/plant/processing/processing-detail-list/index',
  272. params: { id: item?.id },
  273. });
  274. };
  275. //获取所选类型的数量
  276. const selectNumber = async () => {
  277. const res = await useClientRequest.get('/plt-api/app/processe/processCountList');
  278. if (res) {
  279. console.log(res);
  280. processCountList.value = res?.data;
  281. return res;
  282. }
  283. };
  284. const onRefresh = () => {
  285. paging.value?.reload();
  286. };
  287. onMounted(() => {
  288. uni.$on('updateprocesstasklist', function () {
  289. paging.value?.reload();
  290. });
  291. });
  292. onShow(() => {
  293. selectNumber();
  294. });
  295. </script>
  296. <style scoped lang="scss">
  297. .search-select-item {
  298. height: 86rpx;
  299. background-color: #fff;
  300. border-radius: 10rpx;
  301. box-sizing: border-box;
  302. padding: 12rpx;
  303. }
  304. </style>