index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" safe-area-inset-bottom>
  3. <template #top>
  4. <ut-navbar :title="title" :fixed="false"> </ut-navbar>
  5. </template>
  6. <view class="pd-24">
  7. <Task_card :data="taskDate" />
  8. <view class="d-flex a-c j-sb pt-40 pb-40">
  9. <view class="startline-title">管理记录</view>
  10. <view class="d-flex a-c gap-10">
  11. <view v-if="taskDate?.taskType == '2' || taskDate?.taskType == '21'" class="bg-#18BECA radius-10 pd4-10-20-10-20 d-flex a-c" style="width: max-content" @click="addInputMaterialRecord()">
  12. <up-icon name="plus" color="#fff" size="24rpx"></up-icon>
  13. <view class="c-#fff f-s-22">添加投入物料记录</view>
  14. </view>
  15. <view class="bg-#37A954 radius-10 pd4-10-20-10-20 d-flex a-c" style="width: max-content" @click="addManagementRecord()">
  16. <up-icon name="plus" color="#fff" size="24rpx"></up-icon>
  17. <view class="c-#fff f-s-22">添加管理记录</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view v-if="taskDate?.taskType == '2' || taskDate?.taskType == '21'" class="d-flex a-c">
  22. <up-tabs :list="list1" @change="changeType" lineWidth="30"></up-tabs>
  23. <ut-search ref="searchRef" v-model="from.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜管理类型、物料、记录人" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  24. </view>
  25. <ut-search v-else ref="searchRef" v-model="from.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜管理类型、物料、记录人" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  26. <view class="pd-10"></view>
  27. <up-swipe-action>
  28. <up-swipe-action-item v-for="(item, index) in list" :key="index" :name="item?.id" :options="options2" class="mb-20" @click="clickTempSwipe">
  29. <view v-if="+item?.activityType == 1" class="bg-#fff b-radius pd-24" @click="gotoDetail(item)">
  30. <view class="d-flex a-c j-sb">
  31. <view class="f-s-34 f-w-5 pb-10" v-if="item?.opMethod !== '99'">{{ selectDictLabel(+taskDate.baseType == 1 ? pt_op_method : +taskDate.baseType == 2 ? pt_raise_op_method : pt_breed_op_method, item?.opMethod) }}</view>
  32. <view class="f-s-34 f-w-5 pb-10" v-else>{{ item?.cusOp }}</view>
  33. <view class="d-flex a-c">
  34. <view class="f-s-22 c-#666">{{ item?.activityStart }}</view>
  35. <view class="f-s-22 c-#666">至</view>
  36. <view class="f-s-22 c-#666">{{ item?.activityEnd }}</view>
  37. </view>
  38. </view>
  39. <view class="d-flex pd4-8-0-8-0" v-if="item?.inputMaterialList?.length == 0">
  40. <view class="c-#666 f-s-28 w-s-no">使用物料:</view>
  41. <view class="c-#333 f-s-28 f-w-5 w-s-no tx-ov ov-hd">
  42. <view v-for="(data, indexs) in item?.inputMaterialList">
  43. <text v-if="indexs !== 0">、</text>
  44. <text>{{ data?.materialName }}({{ data?.quantity }}{{ data?.unit }})</text>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="item?.mgName" class="d-flex pd4-8-0-8-0">
  49. <view class="c-#666 f-s-28">记录人:</view>
  50. <view class="c-#333 f-s-28 f-w-5">{{ item?.mgName }}</view>
  51. </view>
  52. <view v-if="item?.targetType == '1'" class="d-flex pd4-8-0-8-0">
  53. <view class="c-#666 f-s-28 w-s-no">操作地块:</view>
  54. <view class="c-#333 f-s-28 f-w-5" v-if="+item?.landFlag">全部{{ +taskDate?.baseType == 1 ? '地块' : +taskDate?.baseType == 2 ? '圈舍' : '培养架' }}</view>
  55. <view class="c-#333 f-s-28 f-w-5 d-flex a-c w-s-no tx-ov ov-hd" v-else>
  56. <template v-if="item?.lands?.length == 0">
  57. <text>{{ '-' }}</text>
  58. </template>
  59. <view v-else v-for="(data, indexs) in item?.lands">
  60. <text v-if="indexs !== 0">、</text>
  61. <text>{{ data?.landName }}</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view v-else class="d-flex pd4-8-0-8-0">
  66. <view class="c-#666 f-s-28 w-s-no">操作个体:</view>
  67. <template v-if="item?.animalIds?.length == 0">
  68. <text>{{ '-' }}</text>
  69. </template>
  70. <view v-else v-for="(data, indexs) in item?.animalIds">
  71. <text v-if="indexs !== 0">、</text>
  72. <text class="c-#333 f-s-28 f-w-5">{{ data }}</text>
  73. </view>
  74. </view>
  75. <view v-if="item?.remark" class="d-flex pd4-8-0-8-0">
  76. <view class="c-#666 f-s-28 w-s-no">备注:</view>
  77. <view class="c-#333 f-s-28 f-w-5 w-s-no tx-ov ov-hd">{{ item?.remark }}</view>
  78. </view>
  79. </view>
  80. <view v-if="+item?.activityType == 2" class="bg-#fff b-radius pd-24" @click="gotoDetail(item)">
  81. <view class="d-flex a-c j-sb">
  82. <view class="f-s-34 f-w-5 pb-10">{{ item?.activityName }}</view>
  83. </view>
  84. <view class="d-flex pd4-8-0-8-0">
  85. <view class="c-#666 f-s-28 w-s-no">农资名称:</view>
  86. <view class="c-#333 f-s-28 f-w-5 w-s-no tx-ov ov-hd">
  87. <view v-for="(data, indexs) in item?.inputMaterialList">
  88. <text v-if="indexs !== 0">、</text>
  89. <text>{{ data?.materialName }}</text>
  90. </view>
  91. </view>
  92. </view>
  93. <view v-if="item?.mgName" class="d-flex pd4-8-0-8-0">
  94. <view class="c-#666 f-s-28">记录人:</view>
  95. <view class="c-#333 f-s-28 f-w-5">{{ item?.mgName }}</view>
  96. </view>
  97. <view v-if="item?.mgName" class="d-flex pd4-8-0-8-0">
  98. <view class="c-#666 f-s-28">投入量:</view>
  99. <view class="c-#333 f-s-28 f-w-5">{{ item?.inputMaterialList[0]?.quantity }}{{ item?.inputMaterialList[0]?.unit }}</view>
  100. </view>
  101. <view v-if="item?.remark" class="d-flex pd4-8-0-8-0">
  102. <view class="c-#666 f-s-28 w-s-no">说明:</view>
  103. <view class="c-#333 f-s-28 f-w-5 w-s-no tx-ov ov-hd">{{ item?.remark }}</view>
  104. </view>
  105. </view>
  106. </up-swipe-action-item>
  107. </up-swipe-action>
  108. </view>
  109. </z-paging>
  110. </template>
  111. ß
  112. <script setup lang="ts">
  113. import { useClientRequest } from '@/utils/request';
  114. import Task_card from './models/task_card.vue';
  115. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  116. const { pt_op_method, pt_breed_op_method, pt_raise_op_method } = toRefs<any>(proxy?.useDict('pt_op_method', 'pt_breed_op_method', 'pt_raise_op_method'));
  117. const paging = ref();
  118. const list = ref<any>([]);
  119. const taskId = ref('');
  120. const taskDate = ref<any>();
  121. const from = ref({
  122. keyword: '',
  123. activityType: '',
  124. });
  125. const title = ref('种植管理');
  126. const list1 = reactive([
  127. { name: '全部', value: '' },
  128. { name: '管理记录', value: 1 },
  129. { name: '投料记录', value: 2 },
  130. ]);
  131. const changeType = (tabItem: any) => {
  132. from.value.activityType = tabItem.value;
  133. paging.value.reload();
  134. };
  135. const query = async (pageNo: number, pageSize: number) => {
  136. const res = await useClientRequest.get('/plt-api/app/plantationActivity/list', {
  137. pageNo,
  138. pageSize,
  139. ...from.value,
  140. taskId: taskId.value,
  141. });
  142. if (res) {
  143. const { rows } = res;
  144. paging.value.complete(rows);
  145. }
  146. };
  147. // 添加管理记录
  148. const addManagementRecord = () => {
  149. console.log(taskDate?.value);
  150. if (taskDate?.value?.taskType == '1') {
  151. uni.$u.route({
  152. type: 'navigateTo',
  153. url: '/plant/port/supervise/supervise-plant-create/index',
  154. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 1, id: taskDate?.value?.id },
  155. });
  156. } else if (taskDate?.value?.taskType == '11') {
  157. uni.$u.route({
  158. type: 'navigateTo',
  159. url: '/plant/port/supervise/supervise-breeding-create/index',
  160. //参数说明 baseId:基地id,taskId:任务id,add:1新增,id:任务id,landType:地块类型
  161. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 1, id: taskDate?.value?.id, landType: taskDate?.value?.lands[0]?.landType, variety: taskDate?.value?.variety },
  162. });
  163. } else if (taskDate?.value?.taskType == '2' || taskDate?.value?.taskType == '21') {
  164. uni.$u.route({
  165. type: 'navigateTo',
  166. url: '/plant/port/supervise/supervise-raising-create/index',
  167. //参数说明 baseId:基地id,taskId:任务id,add:1新增,id:任务id,landType:地块类型
  168. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 1, id: taskDate?.value?.id, landType: taskDate?.value?.lands[0]?.landType, variety: taskDate?.value?.variety },
  169. });
  170. }
  171. };
  172. //添加投入物料记录
  173. const addInputMaterialRecord = () => {
  174. console.log('添加投入物料记录');
  175. uni.$u.route({
  176. type: 'navigateTo',
  177. url: '/plant/port/supervise/supervise-material-create/index',
  178. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 1, id: taskDate?.value?.id },
  179. });
  180. };
  181. const changeSeach = async () => {
  182. paging.value.reload();
  183. };
  184. const options2 = reactive([
  185. {
  186. text: '删除',
  187. style: {
  188. backgroundColor: '#F74C30',
  189. width: '80rpx',
  190. fontSize: '28rpx',
  191. },
  192. },
  193. {
  194. text: '编辑',
  195. style: {
  196. backgroundColor: '#37A954',
  197. width: '80rpx',
  198. fontSize: '28rpx',
  199. },
  200. },
  201. ]);
  202. const clickTempSwipe = async (event: object) => {
  203. const { name, index } = event as any;
  204. // 在list中id找到对应的name
  205. const activityType = list.value.find((item: any) => item.id === name)?.activityType;
  206. list.value.forEach((item: any) => {});
  207. if (index === 0) {
  208. try {
  209. const res = await uni.showModal({
  210. title: '删除提示',
  211. content: '删除后,将不能恢复,请谨慎操作!若已使用物料,删除后物料将自动退回相应仓库。',
  212. confirmColor: '#F74C30',
  213. });
  214. if (!res.confirm) return;
  215. await uni.showLoading({
  216. title: '删除中...',
  217. mask: true,
  218. });
  219. await useClientRequest.get(`/plt-api/app/plantationActivity/deleteActivity/${name}`);
  220. uni.hideLoading();
  221. uni.showToast({
  222. title: '删除成功',
  223. icon: 'success',
  224. });
  225. paging.value?.reload();
  226. } catch (error) {
  227. console.error('删除任务失败:', error);
  228. }
  229. } else {
  230. if (activityType == '2') {
  231. uni.$u.route({
  232. type: 'navigateTo',
  233. url: '/plant/port/supervise/supervise-material-create/index',
  234. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 0, id: name },
  235. });
  236. } else if (taskDate?.value?.taskType == '1') {
  237. uni.$u.route({
  238. type: 'navigateTo',
  239. url: `/plant/port/supervise/supervise-plant-create/index`,
  240. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 0, id: name },
  241. });
  242. } else if (taskDate?.value?.taskType == '11' || taskDate?.value?.taskType == '21') {
  243. uni.$u.route({
  244. type: 'navigateTo',
  245. url: '/plant/port/supervise/supervise-breeding-create/index',
  246. //参数说明 baseId:基地id,taskId:任务id,add:1新增,id:任务id,landType:地块类型
  247. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 0, id: name, landType: taskDate?.value?.baseType },
  248. });
  249. } else {
  250. uni.$u.route({
  251. type: 'navigateTo',
  252. url: '/plant/port/supervise/supervise-raising-create/index',
  253. //参数说明 baseId:基地id,taskId:任务id,add:1新增,id:任务id,landType:地块类型
  254. params: { baseId: taskDate?.value?.baseId, taskId: taskId.value, add: 0, id: name, landType: taskDate?.value?.baseType },
  255. });
  256. }
  257. }
  258. };
  259. const gotoDetail = async (item: any) => {
  260. if (item?.activityType == '2') {
  261. uni.$u.route({
  262. type: 'navigateTo',
  263. url: `/plant/port/supervise/supervise-material-detail/index`,
  264. params: {
  265. id: item?.id,
  266. },
  267. });
  268. } else if (item?.activityType == '1') {
  269. uni.$u.route({
  270. type: 'navigateTo',
  271. url: `/plant/port/supervise/supervise-plant-detail/index`,
  272. params: {
  273. id: item?.id,
  274. },
  275. });
  276. }
  277. };
  278. onMounted(async () => {
  279. const res = await useClientRequest.get(`/plt-api/app/plantationTask/getInfo/${taskId.value}`, {
  280. pageNo: 1,
  281. pageSize: 10,
  282. });
  283. taskDate.value = res.data;
  284. if (taskDate.value?.baseType == '1') {
  285. title.value = '种植管理';
  286. } else if (taskDate.value?.baseType == '2') {
  287. title.value = '饲养管理';
  288. } else {
  289. title.value = '繁育管理';
  290. }
  291. });
  292. onLoad((options: any) => {
  293. taskId.value = options?.id;
  294. //接收 uni.$emit('updatesuperviselist');
  295. uni.$on('updatesuperviselist', () => {
  296. paging.value?.reload();
  297. });
  298. });
  299. </script>