123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- <template>
- <view class="home padding-bottom">
- <cu-custom class="home-custom" bgColor=".bg-sancolor"
- bgImage="https://ahwgh.oss-cn-hangzhou.aliyuncs.com/enterprise/6525f808df760.png" :isBack="true">
- <block slot="content">企业抽检</block>
- </cu-custom>
- <view class="cu-form-group solid-bottom">
- <view class="title text-xl text-bold">
- <text class="cuIcon cuIcon-titles text-blue"></text>
- 抽样主体列表
- </view>
- <view>抽样批次数:
- <text class="text-bold text-lg">{{ batchNumber }}</text>
- </view>
- </view>
- <view class="padding-sm" style="margin-bottom: 130rpx">
- <view class="cu-list menu margin-top-sm taskDetail bg-white"
- v-for="(item, index) in sampleList" :key="index">
- <view class="cu-item">
- <view class="content text-black text-bold">
- <text class="cuIcon-titles text-green">{{ index + 1 }}.</text>
- {{ item.bySampleUnitName }}
- </view>
- <view class="action">
- </view>
- </view>
- <view class="content padding-sm detail solid-bottom">
- <view class="text-bold text-orange">当前状态:{{ setSampleStatus(item.sampleStatus) }}</view>
- <view>抽检样品:{{ item.mustProductName }}
- </view>
- <view>负责人:{{ item.bySampleContactName }}</view>
- <view>联系电话:{{ item.bySampleContactPhone }}</view>
- <view style="height: auto">企业地址:{{ item.bySampleAddress.replaceAll(",", "").replaceAll(" ", "")
- }}
- </view>
- </view>
- <view class="tools" style="justify-content: space-between">
- <view>
- </view>
- <!-- <view class="tool" v-if="item.ahTasks.status ==='TASK_RUNNING'"
- @tap="handleTaskDetail(item)">
- <view class="cu-tag bg-blue light text-df text-bold">去抽样 >></view>
- </view>-->
- <view class="tool" @tap="toFillSample(item)">
- <view class="text-blue text-df text-bold text">
- {{ getBtnName(item.sampleStatus) }}>>
- </view>
- </view>
- </view>
- </view>
- <view class="radius shadow-warp bg-white text-lg" v-if="sampleList.length === 0">
- <view class="cu-list menu-avatar">
- <view class="cu-item">
- <view class="content">
- <view class="text-sm text-center" style="justify-content: center;">
- <text class="text-cut text-lg">
- <text class="cuIcon-warn text-yellow margin-right-xs text-xl"></text>
- 未添加抽检主体数据
- </text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="padding flex flex-direction padding-bottom-xl fixedFootBtn bg-white padding-top">
- <button class="cu-btn bg-blue lg shadow-blur" type="" @tap="showFirstProductChoose"
- :disabled="sampleList.length >= batchNumber">抽取抽检主体
- </button>
- </view>
- <view class="cu-modal bottom-modal" :class="modalName==='productListModal'?'show':''">
- <view class="cu-dialog" @tap.stop.prevent>
- <view class="cu-bar bg-white">
- <view class="action text-blue" @tap="hideModal">取消</view>
- <view class="content text-bold">选择抽检样品</view>
- </view>
- <view class="bg-white">
- <view class="cu-bar search bg-white">
- <view class="search-form radius text-left">
- <text class="cuIcon-search"></text>
- <input type="text" placeholder="输入样品名称搜索" confirm-type="search"
- v-model="queryProName" />
- <text class="cuIcon cuIcon-close endClass text-xxl text-bold" @tap="resetQymcQuery"
- v-show="queryProName !== ''"></text>
- </view>
- <view class="action"><!-- 全部的按钮 -->
- <button class="cu-btn bg-green shadow-blur round" @tap="searchProduct">搜索</button>
- </view>
- </view>
- <scroll-view scroll-y class="productScroll padding" @scrolltolower="getProductList">
- <radio-group @change="productNameChange">
- <view class="flex flex-wrap">
- <view class="basis-df padding-xs text-left" v-for="(item,index) in productList"
- :key="index">
- <checkbox :value="item.productName" class="radio" :id="'productName'+index"
- :checked="sampleRandom.productName === item.productName"></checkbox>
- <label :for="'productName'+index">{{ item.productName }}</label>
- </view>
- </view>
- </radio-group>
- </scroll-view>
- </view>
- </view>
- </view>
- <view class="cu-modal" :class="modalName==='SureProductNameModal'?'show':''">
- <view class="cu-dialog">
- <view class="cu-bar bg-white justify-end">
- <view class="content">抽检企业</view>
- <view class="action" @tap="hideModal">
- <text class="cuIcon-close text-red"></text>
- </view>
- </view>
- <view class="padding-left padding-right padding-bottom-sm cu-list menu bg-white">
- <view class="cu-form-group">
- <view class="title">抽样样品名称</view>
- <picker :disabled="true" @tap="modalName = 'productListModal'">
- <view class="picker">
- {{ sampleRandom.productName }}
- </view>
- </picker>
- </view>
- <view class="cu-form-group" v-if="!isCounty">
- <view class="title">所属区域</view>
- <picker :range="regionArray" @change="RegionChange"
- :value="selectIndex">
- <view class="picker">
- {{ regionArray[selectIndex] || "请选择区域" }}
- </view>
- </picker>
- </view>
- <view class="cu-form-group solid-bottom">
- <view class="title">抽检主体数量</view>
- <input type="number" v-model.trim="sampleRandom.enterprisesNum"
- placeholder="请输入抽检主体数量">
- </view>
- <view class="text-right padding-right text-gray padding-top-sm"
- v-show="lastCmpNum !== null && lastCmpNum >= 0">
- <text>剩余可抽取主体:
- <text class="text-bold text-lg">{{ lastCmpNum }}</text>
- 家
- </text>
- </view>
- </view>
- <view class="padding flex flex-direction">
- <button class="cu-btn bg-green lg shadow-blur" type="" @tap="getEnterprisesList"
- :disabled="lastCmpNum == null || lastCmpNum === 0">抽取
- </button>
- </view>
- </view>
- </view>
- <view class="cu-modal" :class="modalName=='onSureSampleEnterpriseModel'?'show':''">
- <view class="cu-dialog">
- <view class="cu-bar bg-white justify-end">
- <view class="content">待确认抽检主体</view>
- <view class="action" @tap="hideModal">
- <text class="cuIcon-close text-red"></text>
- </view>
- </view>
- <view class="padding-left padding-right padding-bottom-sm cu-list menu bg-white">
- <scroll-view class="text-content" scroll-y>
- <view class="cu-item">
- <view class="title text-black text-bold text-lg text-left"
- v-for="(item,index) in onSureEnterpriseList"
- :key="index">
- <text class="cuIcon-title text-green margin-right-xs"></text>
- <text>{{ item.enterprisesName }}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="cu-bar bg-green light" @tap="createSampleSheetList">
- <view class="action margin-0 flex-sub">确认</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- _sampleRandom
- } from "./sample-random-model";
- import { _taskList } from "../../task-list/task-list-model";
- export default {
- data() {
- return {
- taskId: null,
- sampleCheckId: null,
- batchNumber: 0,
- sampleRandom: {
- productName: "",
- enterprisesNum: ""
- },
- onSureEnterpriseList: [],
- productList: [],
- taskListData: [],
- taskTypeList: [],
- taskDetailList: [],
- taskStatus: [],
- modalName: null,
- xzqdm: null,
- pageTotal: 1,
- totalCount: 0,
- page: 1,
- size: 40,
- samplePage: 1,
- sampleSize: 10,
- samplePageTotal: 1,
- sampleTotalCount: 0,
- sampleList: [],
- zfrSelected: [],
- serviceZfrSelected: [],
- queryProName: "",
- subXzqList: [],
- selectIndex: null,
- lastCmpNum: null,
- sampleStatus: [],
- isCounty:false
- };
- },
- onLoad(param) {
- this.page = 1;
- this.pageTotal = 1;
- this.taskId = param.taskId;
- this.batchNumber = param.batchNumber;
- this.sampleCheckId = param.sampleCheckId;
- this.xzqdm = param.sampleId;
- if (this.xzqdm.endsWith("000") && !this.xzqdm.endsWith("00000")) {
- this.isCounty = true;
- }
- this.getProductList();
- this.getSampleCheckList();
- this.initXzqRange();
- this.getSampleStatus();
- },
- computed: {
- regionArray() {
- return this.subXzqList.map(v => v.xzqmc);
- },
- selectXzqCode() {
- if(this.isCounty){
- return this.xzqdm;
- } else {
- if (this.selectIndex !== null) {
- return this.subXzqList[this.selectIndex].xzqdm;
- }
- }
- }
- },
- methods: {
- showFirstProductChoose() {
- this.sampleRandom.enterprisesNum = null;
- this.sampleRandom.productName = null;
- this.modalName = "productListModal";
- },
- getSampleCheckList() {
- if (this.samplePage === 1 || (this.samplePage <= this.samplePageTotal)) {
- _sampleRandom.getSampleCheckList({
- pageNum: this.samplePage,
- pageSize: this.sampleSize,
- sampleCheckId: this.sampleCheckId
- }, res => {
- const { data, message, code } = res;
- if (code === 200) {
- const { records, total } = data;
- this.sampleTotalCount = total;
- this.samplePageTotal = Math.ceil(total / this.sampleSize);
- if (this.samplePage === 1) {
- this.sampleList = records;
- } else {
- this.sampleList = this.sampleList.concat(records);
- }
- this.samplePage++;
- } else {
- uni.showToast({
- icon: "none",
- title: message,
- duration: 1000
- });
- }
- });
- }
- },
- searchProduct() {
- this.page = 1;
- this.pageTotal = 1;
- this.getProductList();
- },
- resetQymcQuery() {
- this.queryProName = "";
- this.searchProduct();
- },
- getProductList() {
- if (this.page === 1 || (this.page <= this.pageTotal)) {
- _sampleRandom.getProductList({
- pageNum: this.page,
- pageSize: this.size,
- xzqCode: this.xzqdm,
- productName: this.queryProName
- }, res => {
- const { data, message, code } = res;
- if (code === 200) {
- const { list, total } = data;
- this.totalCount = total;
- this.pageTotal = Math.ceil(total / this.size);
- if (this.page === 1) {
- this.productList = list;
- } else {
- this.productList = this.productList.concat(list);
- }
- this.page++;
- } else {
- uni.showToast({
- icon: "none",
- title: message,
- duration: 1000
- });
- }
- });
- }
- },
- getEnterPrisesNum() {
- if (this.selectXzqCode !== "" && this.selectXzqCode !== null && this.sampleRandom.productName) {
- _sampleRandom.getEnterPrisesNum({
- xzqCode: this.selectXzqCode,
- productName: this.sampleRandom.productName
- }, res => {
- this.lastCmpNum = res.data;
- });
- } else {
- this.lastCmpNum = null;
- }
- },
- showModal(e) {
- this.modalName = e.currentTarget.dataset.target;
- _sampleRandom.getTaskSampleDetail(e.currentTarget.dataset.taskid, res => {
- this.taskDetailList = res.data.records;
- });
- },
- hideModal(e) {
- this.curTask = null;
- this.modalName = null;
- },
- createSampleSheetList() {
- if (this.onSureEnterpriseList.length <= 0) {
- this.$msg("抽检企业为空");
- return;
- }
- const postData = this.onSureEnterpriseList.map(v => {
- return {
- bySampleAddress: v.enterprisesAddress,
- bySampleContactName: v.fzrName,
- bySampleContactPhone: v.fzrPhone,
- bySampleUnitName: v.enterprisesName,
- mustProductName: this.sampleRandom.productName,
- qydm: v.qydm,
- taskId: this.taskId,
- sampleCheckId: this.sampleCheckId
- };
- });
- _sampleRandom.createSampleSheetList(postData, res => {
- const { code, message } = res;
- if (code === 200) {
- this.$msg("添加成功");
- this.modalName = null;
- this.samplePage = 1;
- this.samplePageTotal = 1;
- this.getSampleCheckList();
- } else {
- this.$msg(message);
- }
- });
- },
- getEnterprisesList() {
- // this.onSureEnterpriseList = true;
- if (!this.isCounty && this.selectIndex === null) {
- this.$msg("请选择抽样区域");
- return;
- }
- const postData = Object.assign({}, this.sampleRandom);
- if (!postData.productName) {
- this.$msg("请选择抽样样品名称");
- return;
- }
- if (parseInt(postData.enterprisesNum) <= 0 || "" + parseInt(postData.enterprisesNum) === "NaN") {
- this.$msg("请输入抽检主体数量");
- return;
- }
- if (parseInt(postData.enterprisesNum) + this.sampleList.length > this.batchNumber) {
- this.$msg("抽取企业总数不可超过抽样批次数");
- return;
- }
- if (parseInt(postData.enterprisesNum) > parseInt(this.lastCmpNum)) {
- this.$msg("抽检主体数量应小于等于剩余主体数量");
- return;
- }
- postData.xzqCode = this.selectXzqCode;
- postData.taskId = this.taskId;
- _sampleRandom.getEnterprisesList(postData, res => {
- if (!res.data || res.data.length === 0) {
- this.$msg("当前地区无可抽取企业");
- } else {
- this.onSureEnterpriseList = res.data;
- this.modalName = "onSureSampleEnterpriseModel";
- }
- });
- },
- setTaskType(taskType) {
- const taskTypeList = this.taskTypeList;
- for (let i = 0; i < taskTypeList.length; i++) {
- if (taskTypeList[i].itemValue === taskType) {
- return taskTypeList[i].itemKey;
- }
- }
- },
- setTaskStatus(value) {
- let taskStatus = this.taskStatus;
- for (let i = 0; i < taskStatus.length; i++) {
- if (taskStatus[i].itemValue === value) {
- return taskStatus[i].itemKey;
- }
- }
- },
- formatDate(dateTime) {
- return dateTime.substring(0, 10);
- },
- productNameChange(e) {
- const productName = e.detail.value;
- if (productName) {
- this.sampleRandom.productName = productName;
- this.getEnterPrisesNum();
- this.modalName = "SureProductNameModal";
- }
- },
- initXzqRange() {
- _sampleRandom.getXzqdmSubLists(this.xzqdm, city_res => {
- const { code, data } = city_res;
- if (code === 200) {
- this.subXzqList = data;
- }
- });
- },
- RegionChange(e) {
- this.selectIndex = e.detail.value;
- this.getEnterPrisesNum();
- },
- getSampleStatus() {
- _taskList.getDictionary("SAMPLE_SHEET_STATUS", res => {
- this.sampleStatus = res.data;
- });
- },
- setSampleStatus(value) {
- console.log("setSampleStatus",value);
- let sampleStatus = this.sampleStatus;
- for (let i = 0; i < sampleStatus.length; i++) {
- if (sampleStatus[i].itemValue === value) {
- return sampleStatus[i].itemKey;
- }
- }
- },
- toFillSample(item) {
- uni.navigateTo({
- url: "/pages/sample-detail/index?id=" + item.id
- });
- },
- getBtnName(status) {
- let name = "查看";
- if (status === "WAIT_SAMPLE") {
- name = "填报抽样单";
- }
- return name;
- }
- }
- };
- </script>
- <style scoped>
- .detail view {
- font-size: 31rpx;
- height: 1.8em;
- line-height: 1.8em !important;
- border: none;
- }
- .taskDetail {
- /*border: 1rpx solid #8799a3;*/
- box-shadow: 0 0 25upx #aaa;
- border-radius: 10rpx;
- overflow: hidden;
- }
- label {
- padding-left: .5em;
- }
- .productScroll {
- height: 30em;
- max-height: 60vh;
- }
- .fixedFootBtn {
- border-top: 1px solid #ddd;
- position: fixed;
- width: 100vw;
- bottom: 0;
- z-index: 1000;
- }
- .tools {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 30upx;
- }
- .tool .text {
- font-size: 1.1em !important;
- }
- </style>
|