| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592 |
- <!--
- * @Author: 倚楼听风雨 18408246387@163.com
- * @Date: 2022-11-16 17:16:17
- * @LastEditors: 倚楼听风雨 18408246387@163.com
- * @LastEditTime: 2023-03-30 16:20:57
- * @FilePath: \log-server-web\src\view\rentComputer\rent_computer.vue
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- -->
- <template>
- <div>
- <div class="gva-search-box">
- <div class="gva-btn-list">
- <el-form ref="searchForm" :inline="true" :model="searchInfo">
- <el-form-item label="电脑编号">
- <el-input
- v-model="searchInfo.pc_num"
- placeholder="编号"
- size="small"
- />
- </el-form-item>
- <el-form-item label="供应商">
- <el-select v-model="searchInfo.shop_id" size="small">
- <el-option
- v-for="item in shopOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="套餐">
- <el-select v-model="searchInfo.set_meal_id" size="small"
- ><el-option
- v-for="item in setMealOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- /></el-select>
- </el-form-item>
- <el-form-item label="是否到期">
- <el-select v-model="searchInfo.is_expire" size="small">
- <el-option label="否" value="0" />
- <el-option label="是" value="1" />
- <el-option label="明日到期" value="2" />
- <el-option label="一周内到期" value="3" />
- </el-select>
- </el-form-item>
- <el-form-item label="使用人">
- <el-select v-model="searchInfo.director_name" size="small">
- <el-option
- v-for="item in directorOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="是否下架">
- <el-select v-model="searchInfo.is_off_shelf" size="small">
- <el-option label="否" value="0" />
- <el-option label="是" value="1" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- size="small"
- type="primary"
- icon="search"
- @click="onSubmit"
- >查询</el-button
- >
- <el-button size="small" icon="refresh" @click="onReset"
- >重置</el-button
- >
- </el-form-item>
- </el-form>
- </div>
- <div class="gva-btn-list">
- <el-button size="small" type="primary" icon="plus" @click="addMenu('0')"
- >新增</el-button
- >
- <el-button
- class="excel-btn"
- size="small"
- type="success"
- icon="download"
- @click="downloadExcelTemplate()"
- >下载模板</el-button
- >
- <el-upload
- style="margin-left: 1%"
- class="excel-btn"
- :action="`${path}/rentComputer/importExcel`"
- :headers="{ 'x-token': userStore.token }"
- :on-success="loadExcel"
- :show-file-list="false"
- >
- <el-button size="small" type="primary" icon="upload">导入</el-button>
- </el-upload>
- <el-button
- icon="delete"
- size="small"
- type="danger"
- :disabled="!apis.length"
- style="margin-left: 10px"
- @click="deletesMenu()"
- >删除</el-button
- >
- <el-button
- icon="money"
- size="small"
- type="success"
- :disabled="!apis.length"
- style="margin-left: 10px"
- @click="switchRenews()"
- >批量续费</el-button
- >
- </div>
- </div>
- <div class="row center">
- <el-tag size="large">电脑数量 : {{ computerNum }} </el-tag>
- <el-tag
- size="large"
- type="danger"
- hit
- effect="dark"
- style="margin-left: 20px"
- v-if="tagExpire"
- >有租机即将到期,请注意续费!!!</el-tag
- >
- </div>
- <div class="gva-table-box">
- <!-- <el-scrollbar height="550px"> -->
- <el-table
- height="500px"
- :data="tableData"
- @sort-change="sortChange"
- @selection-change="handleSelectionChange"
- border
- v-loading="loading"
- >
- <el-table-column type="selection" width="55" />
- <el-table-column
- align="left"
- label="供应商"
- min-width="70"
- prop="shop_name"
- />
- <!-- <el-table-column
- align="left"
- label="套餐"
- min-width="100"
- prop="set_meal_name"
- /> -->
- <el-table-column
- align="center"
- label="套餐"
- min-width="150"
- prop="set_meal_name"
- >
- <template #default="scope">
- <span v-if="scope.row.price_type == 0">{{
- scope.row.set_meal_name + "-天卡(" + scope.row.rent_price + "元)"
- }}</span>
- <span v-else-if="scope.row.price_type == 1">{{
- scope.row.set_meal_name + "-周卡(" + scope.row.rent_price + "元)"
- }}</span>
- <span v-else>{{
- scope.row.set_meal_name + "-月卡(" + scope.row.rent_price + "元)"
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- align="left"
- label="编号"
- min-width="80"
- prop="pc_num"
- />
- <el-table-column
- align="left"
- label="名称"
- min-width="80"
- prop="pc_name"
- />
- <el-table-column
- align="left"
- label="起租时间"
- min-width="150"
- prop="rent_start"
- />
- <el-table-column
- align="left"
- label="到期时间"
- min-width="150"
- prop="rent_end"
- />
- <el-table-column
- align="left"
- label="租期"
- min-width="50"
- prop="rent_duration"
- />
- <el-table-column
- align="left"
- label="使用人"
- min-width="80"
- prop="director_name"
- />
- <el-table-column
- align="center"
- label="是否到期"
- min-width="100"
- prop="is_expire"
- >
- <template #default="scope">
- <el-button
- v-if="scope.row.is_expire == 3"
- size="small"
- type="warning"
- plain
- >即将到期</el-button
- >
- <el-button
- v-else-if="scope.row.is_expire == 2"
- size="small"
- type="danger"
- plain
- >明日到期</el-button
- >
- <el-button
- v-else-if="scope.row.is_expire == 1"
- size="small"
- type="info"
- plain
- >到期未续</el-button
- >
- <el-button v-else size="small" type="success" plain
- >在租期中</el-button
- >
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="是否下架"
- min-width="100"
- prop="is_off_shelf"
- >
- <template #default="scope">
- <el-button
- v-if="scope.row.is_off_shelf == 1"
- size="small"
- type="warning"
- plain
- >是</el-button
- >
- <el-button v-else size="small" type="success" plain>否</el-button>
- </template>
- </el-table-column>
- <el-table-column
- align="left"
- label="TD号"
- min-width="100"
- prop="todesk_id"
- />
- <el-table-column
- align="left"
- label="TD密码"
- min-width="100"
- prop="todesk_password"
- />
- <el-table-column
- align="left"
- label="向日葵号"
- min-width="100"
- prop="sunflower_id"
- />
- <el-table-column
- align="left"
- label="向日葵密码"
- min-width="100"
- prop="sunflower_password"
- />
- <el-table-column
- align="left"
- label="最近一次修改日志"
- min-width="250"
- show-overflow-tooltip
- >
- <template #default="scope">
- <el-row>
- <el-col :span="20">
- <span
- style="
- display: block;
- max-width: 15em;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- "
- >{{ scope.row.remark }}</span
- >
- </el-col>
- <el-col :span="4">
- <el-button
- size="small"
- type="warning"
- link
- icon="tickets"
- @click="switchLog(scope.row)"
- >more</el-button
- >
- </el-col>
- </el-row>
- </template>
- </el-table-column>
- <el-table-column
- align="left"
- label="更新时间"
- min-width="150"
- prop="update_time"
- />
- <el-table-column align="left" fixed="right" label="操作" width="430">
- <template #default="scope">
- <el-button
- size="small"
- type="primary"
- link
- icon="link"
- @click="linkTd(scope.row)"
- >TD连接</el-button
- >
- <el-button
- size="small"
- type="primary"
- link
- icon="edit"
- @click="switchRenew(scope.row)"
- >续费</el-button
- >
- <el-button
- v-if="scope.row.is_expire != 1"
- size="small"
- type="primary"
- link
- icon="edit"
- @click="switchRentingOut(scope.row)"
- >退租</el-button
- >
- <el-button
- v-if="scope.row.is_expire != 1"
- size="small"
- type="primary"
- link
- icon="edit"
- @click="switchReplaceNum(scope.row)"
- >换编号</el-button
- >
- <el-button
- v-if="scope.row.is_off_shelf == 0"
- size="small"
- type="primary"
- link
- icon="edit"
- @click="offShelf(scope.row)"
- >下架</el-button
- >
- <el-button
- size="small"
- type="primary"
- link
- icon="edit"
- @click="editMenu(scope.row.id)"
- >编辑</el-button
- >
- <el-button
- size="small"
- type="primary"
- link
- icon="delete"
- @click="deleteMenu(scope.row.id)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <!-- </el-scrollbar> -->
- <div class="gva-pagination">
- <el-pagination
- :current-page="page"
- :page-size="pageSize"
- :page-sizes="[10, 20, 30, 50, 100]"
- :total="total"
- layout="total, sizes, prev, pager, next, jumper"
- @current-change="handleCurrentChange"
- @size-change="handleSizeChange"
- />
- </div>
- </div>
- <el-dialog v-model="dialogFormVisible" :title="dialogTitle">
- <el-form
- v-if="dialogFormVisible"
- ref="menuForm"
- :inline="true"
- :model="form"
- :rules="rules"
- label-position="left"
- label-width="85px"
- >
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item label="电脑编号" prop="pc_num">
- <el-input v-model="form.pc_num" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="电脑名称" prop="pc_name">
- <el-input v-model="form.pc_name" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="供应商" prop="shop_id">
- <el-select v-model="form.shop_id">
- <el-option
- v-for="item in shopOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="套餐名" prop="set_meal_id">
- <el-select v-model="form.set_meal_id">
- <el-option
- v-for="item in setMealOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="使用人" prop="director_name">
- <el-select v-model="form.director_name" size="small">
- <el-option
- v-for="item in directorOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item label="Todesk号" prop="todesk_id">
- <el-input v-model="form.todesk_id" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="Todesk密码" prop="todesk_password">
- <el-input v-model="form.todesk_password" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="向日葵号" prop="sunflower_id">
- <el-input v-model="form.sunflower_id" />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="向日葵密码" prop="sunflower_password">
- <el-input v-model="form.sunflower_password" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10">
- <el-col :span="8">
- <el-form-item label="起租时间" prop="rent_start">
- <el-date-picker
- v-model="form.rent_start"
- type="datetime"
- placeholder="起租时间"
- :default-time="defaultTime"
- @change="calculateRentDuration(form)"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="租赁天数" prop="rent_duration">
- <el-input
- v-model="form.rent_duration"
- @change="calculateRentDuration(form)"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="到期时间" prop="rent_end">
- <el-date-picker
- v-model="form.rent_end"
- type="datetime"
- placeholder="到期时间"
- :default-time="defaultTime"
- readonly
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="10">
- <el-col :span="12">
- <el-form-item label="是否到期" prop="is_expire">
- <el-radio-group v-model="form.is_expire">
- <el-radio :label="0" size="large">在租期中</el-radio>
- <el-radio :label="1" size="large">到期未续</el-radio>
- <el-radio :label="2" size="large">明日到期</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- </el-row>
- <!-- <el-row :gutter="10">
- <el-col :span="12">
- <el-form-item label="是否下架" prop="is_off_shelf">
- <el-switch v-model="form.is_off_shelf" />
- </el-form-item>
- </el-col>
- </el-row> -->
- <el-row :gutter="10">
- <el-col :span="20">
- <el-form-item label="备注" prop="remark">
- <el-input
- v-model="form.remark"
- type="textarea"
- :rows="4"
- style="width: 500px"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button size="small" @click="closeDialog">取 消</el-button>
- <el-button size="small" type="primary" @click="enterDialog"
- >确 定</el-button
- >
- </div>
- </template>
- </el-dialog>
- <!--日志-->
- <el-dialog v-model="visible_log" title="操作日志">
- <el-table :data="logData">
- <el-table-column property="create_time" label="操作时间" width="150" />
- <el-table-column property="pc_num" label="租机编号" width="80" />
- <el-table-column property="log" label="日志" />
- </el-table>
- </el-dialog>
- <!--租机续费-->
- <el-dialog title="租机续费" v-model="visible_renew">
- <el-form :model="renewForm" size="default" label-width="100px">
- <el-row>
- <el-form-item label="警告:" prop="">
- <el-col :span="24">
- <p style="color: red; font-size: larger">请勿随意操作!!!</p>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="租机编号" prop="pc_num">
- <el-col :span="12">
- <el-input
- v-model="renewForm.pc_num"
- placeholder="租机编号"
- :disabled="true"
- ></el-input>
- </el-col>
- </el-form-item>
- <el-form-item label="续费时间" prop="rent_renew">
- <el-col>
- <el-date-picker
- v-model="renewForm.rent_renew"
- format="YYYY-MM-DD HH:mm:ss"
- type="datetime"
- :style="{ width: '100%' }"
- placeholder="请选择日期"
- clearable
- @change="calculateRenewDay(renewForm)"
- ></el-date-picker>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="续费天数" prop="">
- <el-col :span="24">
- <el-tag :key="renewForm.day" type="warning" effect="light">
- {{ renewForm.day }}
- </el-tag>
- </el-col>
- </el-form-item>
- </el-row>
- <el-divider />
- <el-form-item>
- <el-button size="small" @click="visible_renew = false"
- >取消</el-button
- >
- <el-button type="primary" size="small" @click="renew(renewForm)"
- >提交</el-button
- >
- </el-form-item>
- </el-form>
- </el-dialog>
- <!-- 批量续费 -->
- <el-dialog title="批量续费" v-model="visible_renews">
- <p style="color: red; font-size: larger">严重警告:请勿随意操作!!!</p>
- <span style="font-size: larger">续费天数:</span>
- <el-input
- v-model="renewsDay"
- size="small"
- style="width: 30%"
- placeholder="天数"
- ></el-input>
- <el-button
- type="primary"
- style="margin-left: 20px"
- size="small"
- @click="calculateRenewEnd()"
- >计算</el-button
- >
- <p style="font-size: larger">续费明细如下,请认真核对后再提交:</p>
- <el-table size="small" height="400px" :data="renewDatas" border>
- <el-table-column type="index" width="55" />
- <el-table-column
- align="left"
- label="编号"
- min-width="70"
- prop="pc_num"
- />
- <el-table-column
- align="left"
- label="当前到期时间"
- min-width="100"
- prop="rent_end"
- />
- <el-table-column
- align="left"
- label="续费后到期时间"
- min-width="100"
- prop="rent_end_new"
- />
- </el-table>
- <el-divider />
- <el-button size="small" @click="visible_renews = false">取消</el-button>
- <el-button type="primary" size="small" @click="renewByBatch()"
- >提交</el-button
- >
- </el-dialog>
- <!--退租-->
- <el-dialog title="租机退租" v-model="visible_rentingOut">
- <el-form
- ref="elForm"
- :model="rentingOutForm"
- size="medium"
- label-width="100px"
- >
- <el-row>
- <el-form-item label="警告:" prop="">
- <el-col :span="24">
- <p style="color: red; font-size: larger">请勿随意操作!!!</p>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="租机编号" prop="pc_num">
- <el-col :span="12">
- <el-input
- v-model="rentingOutForm.pc_num"
- placeholder="租机编号"
- :disabled="true"
- ></el-input>
- </el-col>
- </el-form-item>
- <el-form-item label="退租时间" prop="rent_end">
- <el-col>
- <el-date-picker
- v-model="rentingOutForm.rent_end"
- format="YYYY-MM-DD HH:mm:ss"
- type="datetime"
- :style="{ width: '100%' }"
- placeholder="请选择日期"
- clearable
- @change="calculateRentDay(rentingOutForm)"
- ></el-date-picker>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="剩余天数" prop="">
- <el-col :span="24">
- <el-tag :key="rentingOutForm.day" type="warning" effect="light">
- {{ rentingOutForm.day }}
- </el-tag>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row
- ><el-col :span="12" style="margin-left: 30px"
- ><el-button size="small" @click="addCardMsg()"
- >匀时间</el-button
- ></el-col
- ></el-row
- >
- <el-row>
- <div class="container-scrollbar">
- <el-scrollbar max-height="200px">
- <el-row
- :gutter="24"
- v-for="(item, index) in cardList"
- :key="index"
- >
- <el-col :span="10">
- <el-form-item label="租机编号">
- <el-input v-model="item.pc_num"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="增加天数">
- <el-input v-model="item.add_day"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="2" v-if="cardList.length !== 1">
- <el-button
- size="mini"
- circle
- icon="delete"
- @click="deleteCardMsg(index)"
- ></el-button>
- </el-col>
- </el-row>
- </el-scrollbar>
- </div>
- </el-row>
- <el-divider />
- <el-form-item>
- <el-button size="small" @click="visible_rentingOut = false"
- >取消</el-button
- >
- <el-button
- type="primary"
- size="small"
- @click="rentingOut(rentingOutForm)"
- >提交</el-button
- >
- </el-form-item>
- </el-form>
- </el-dialog>
- <!--租机编号更换-->
- <el-dialog title="租机编号更换" v-model="visible_replaceNum">
- <el-form
- ref="elForm"
- :model="replaceNumForm"
- size="medium"
- label-width="100px"
- >
- <el-row>
- <el-form-item label="警告:" prop="">
- <el-col :span="24">
- <p style="color: red; font-size: larger">
- 请勿随意更换,会影响租机续费
- </p>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="供应商:" prop="shop_name">
- <el-col :span="24">
- <p>
- <span style="color: red; font-size: larger">{{
- replaceNumForm.shop_name
- }}</span
- >, 只可更改为同一供应商的编号
- </p>
- </el-col>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="原租机编号" prop="pc_num_old">
- <el-col :span="24">
- <el-input
- v-model="replaceNumForm.pc_num_old"
- placeholder="原租机编号"
- :disabled="true"
- ></el-input>
- </el-col>
- </el-form-item>
- <el-form-item label="更换编号" prop="pc_num_new">
- <el-col :span="24">
- <el-input
- v-model="replaceNumForm.pc_num_new"
- placeholder="更换编号"
- ></el-input>
- </el-col>
- </el-form-item>
- </el-row>
- <el-divider />
- <el-form-item>
- <el-button size="small" @click="visible_replaceNum = false"
- >取消</el-button
- >
- <el-button
- type="primary"
- size="small"
- @click="replaceNum(replaceNumForm)"
- >提交</el-button
- >
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- name: "computer",
- };
- </script>
- <script setup>
- import {
- getRentComputerList,
- getRentComputerNum,
- listRentComputerShopList,
- listRentSetMealList,
- getRentComputerById,
- addRentComputer,
- editRentComputer,
- deleteRentComputerById,
- deleteRentComputerByIds,
- renewRentComputer,
- renewRentComputerByBatch,
- replaceNumRentComputer,
- rentingOutRentComputer,
- offShelfRentComputer,
- queryRentComputerLogByPcNum,
- } from "@/api/rentComputer";
- import { getDirectorList } from "@/api/responsiblePerson";
- import { useUserStore } from "@/pinia/modules/user";
- import { toSQLLine } from "@/utils/stringFun";
- import { ref } from "vue";
- import { ElMessage, ElMessageBox, ElLoading } from "element-plus";
- import { formatDate } from "@/utils/format";
- import { downloadTemplate } from "@/api/excel";
- import dayjs from "dayjs";
- const apis = ref([]);
- const form = ref({
- id: 0,
- pc_num: "",
- pc_name: "",
- shop_id: null,
- set_meal_id: null,
- todesk_id: "",
- todesk_password: "",
- sunflower_id: "",
- sunflower_password: "",
- rent_start: new Date(),
- rent_duration: 0,
- rent_end: new Date(),
- remark: "",
- is_expire: -1,
- is_off_shelf: -1,
- director_name: "ALL",
- });
- const rules = ref({
- pc_num: [{ required: true, message: "请输入电脑编号", trigger: "blur" }],
- pc_name: [{ required: true, message: "请输入电脑名称", trigger: "blur" }],
- shop_id: [{ required: true, message: "请选择供应商", trigger: "blur" }],
- set_meal_id: [{ required: true, message: "请选择套餐", trigger: "blur" }],
- rent_start: [{ required: true, message: "请选择起租日期", trigger: "blur" }],
- rent_duration: [
- { required: true, message: "请输入租赁天数", trigger: "blur" },
- ],
- is_expire: [{ required: true, message: "请选择是否到期", trigger: "blur" }],
- is_off_shelf: [
- { required: true, message: "请选择是否下架", trigger: "blur" },
- ],
- });
- const page = ref(1);
- const total = ref(0);
- const pageSize = ref(20);
- const tableData = ref([]);
- const renewDatas = ref([]);
- const logData = ref([]);
- const loading = ref(false);
- const searchInfo = ref({
- is_expire: -1,
- is_off_shelf: -1,
- director_name: "ALL",
- });
- const computerNum = ref("");
- const tagExpire = ref(false);
- const shopOptions = ref();
- const directorOptions = ref();
- const setMealOptions = ref();
- const defaultTime = ref(new Date(2000, 1, 1, 12, 0, 0));
- const path = ref(import.meta.env.VITE_BASE_API);
- const userStore = useUserStore();
- const visible_renew = ref(false);
- const visible_renews = ref(false);
- const visible_rentingOut = ref(false);
- const visible_replaceNum = ref(false);
- const visible_log = ref(false);
- const rent_end = ref("");
- const renewForm = ref({
- pc_num: "",
- pc_id: 0,
- day: 0,
- rent_renew: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
- });
- const renewsDay = ref(0);
- const rentingOutForm = ref({
- pc_num: "",
- pc_id: 0,
- day: 0,
- rent_end: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
- addList: [],
- });
- const replaceNumForm = ref({
- pc_num_old: "",
- pc_num_new: "",
- shop_id: 0,
- shop_name: "",
- });
- let cardList = ref([]);
- // 计算租机到期时间
- const calculateRentDuration = async (scope) => {
- scope.rent_end = new Date(
- Date.parse(scope.rent_start) +
- 1 * 24 * 60 * 60 * 1000 * parseInt(scope.rent_duration)
- );
- };
- // 计算退租剩余时间
- function calculateRentDay(scope) {
- if (Date.parse(rent_end.value) < Date.parse(scope.rent_end)) {
- scope.rent_end = rent_end.value;
- ElMessage.error("退租时间不能大于到期时间");
- }
- scope.day = Math.ceil(
- parseInt(
- (Date.parse(rent_end.value) - Date.parse(scope.rent_end)) /
- (24 * 60 * 60 * 1000) +
- ""
- )
- );
- // console.log(scope.day);
- }
- // 计算续费时间
- function calculateRenewDay(scope) {
- if (Date.parse(rent_end.value) >= Date.parse(scope.rent_renew)) {
- scope.rent_renew = rent_end.value;
- ElMessage.error("续费时间不能小于到期时间");
- visible_renew.value = false;
- }
- scope.day = Math.ceil(
- parseInt(
- (Date.parse(scope.rent_renew) - Date.parse(rent_end.value)) /
- (24 * 60 * 60 * 1000) +
- ""
- )
- );
- }
- // 查询日志
- async function switchLog(rowData) {
- const loadingLog = ElLoading.service({
- lock: true,
- text: "查询日志中...",
- background: "rgba(0, 0, 0, 0.7)",
- });
- let logForm = {
- pc_num: rowData.pc_num,
- shop_id: Number(rowData.shop_id),
- // set_meal_id: Number(rowData.set_meal_id),
- };
- // console.log(logForm);
- const data = await queryRentComputerLogByPcNum(logForm);
- if (data.code == 0) {
- visible_log.value = true;
- loadingLog.close();
- // ElMessage.success(data.msg);
- logData.value = data.data.list;
- } else {
- ElMessage.error(data.msg);
- }
- }
- // 拉起续费弹窗
- async function switchRenew(rowData) {
- // console.log(rowData);
- renewForm.value.pc_num = rowData.pc_num;
- renewForm.value.pc_id = rowData.id;
- renewForm.value.rent_renew = rowData.rent_end;
- renewForm.value.day = 0;
- rent_end.value = rowData.rent_end;
- // console.log(renewForm);
- if (visible_renew.value == false) {
- visible_renew.value = true;
- }
- }
- // 续费
- async function renew(rowData) {
- let doForm = {
- pc_num: rowData.pc_num,
- pc_id: rowData.pc_id,
- rent_renew: dayjs(new Date(rowData.rent_renew)).format(
- "YYYY-MM-DD HH:mm:ss"
- ),
- day: rowData.day,
- };
- // renewRentComputer
- const data = await renewRentComputer(doForm);
- if (data.code == 0) {
- visible_renew.value = false;
- ElMessage.success(data.msg);
- getTableData();
- } else {
- ElMessage.error(data.msg);
- }
- }
- // 拉起批量续费弹窗
- async function switchRenews(rowData) {
- renewDatas.value = [];
- if (visible_renews.value == false) {
- visible_renews.value = true;
- }
- calculateRenewEnd();
- }
- // 计算批量续费到期时间
- function calculateRenewEnd() {
- renewDatas.value = [];
- //
- apis.value.map((item) => {
- // console.log(item);
- let temp = {
- pc_id: item.id,
- pc_num: item.pc_num,
- rent_end: item.rent_end,
- rent_end_new: dayjs(new Date(item.rent_end))
- .add(renewsDay.value, "day")
- .format("YYYY-MM-DD HH:mm:ss"),
- };
- renewDatas.value.push(temp);
- });
- }
- // 批量续费
- const renewByBatch = async () => {
- const loadingByBatch = ElLoading.service({
- lock: true,
- text: "批量续费中,请勿操作界面...",
- background: "rgba(0, 0, 0, 0.7)",
- });
- let rentMessage = [];
- renewDatas.value.map((item) => {
- let temp = {
- pc_num: item.pc_num,
- pc_id: item.pc_id,
- rent_renew: item.rent_end_new,
- day: Number(renewsDay.value),
- };
- rentMessage.push(temp);
- });
- let xxxx = {
- rent_message: rentMessage,
- };
- const data = await renewRentComputerByBatch(xxxx);
- if (data.code == 0) {
- visible_renews.value = false;
- loadingByBatch.close();
- ElMessage.success(data.msg);
- getTableData();
- } else {
- ElMessage.error(data.msg);
- }
- };
- // 拉起退租弹窗
- async function switchRentingOut(rowData) {
- cardList.value = [];
- rentingOutForm.value.pc_num = rowData.pc_num;
- rentingOutForm.value.pc_id = rowData.id;
- rentingOutForm.value.rent_end = dayjs(new Date(rowData.rent_end)).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- rentingOutForm.value.day = 0;
- rent_end.value = rowData.rent_end;
- if (visible_rentingOut.value == false) {
- visible_rentingOut.value = true;
- }
- }
- function addCardMsg() {
- let hasFlag = false;
- for (let i = 0; i < cardList.value.length; i++) {
- if (
- cardList.value[i].pc_num == "" ||
- cardList.value[i].add_day == undefined
- ) {
- hasFlag = true;
- break;
- }
- }
- if (hasFlag == true) {
- ElMessage.error("有未填写项");
- } else {
- cardList.value.push({
- pc_id: "",
- add_day: null,
- });
- }
- }
- function deleteCardMsg(index) {
- cardList.value.splice(index, 1);
- }
- // 退租
- async function rentingOut(rowData) {
- var numDay = 0;
- let AddList = [];
- cardList.value.forEach((e) => {
- numDay += e.add_day;
- let temp = {
- pc_num: e.pc_num,
- add_day: Number(e.add_day),
- };
- AddList.push(temp);
- });
- if (numDay != rowData.day) {
- ElMessage.error("匀时间天数错误!!!");
- return;
- }
- let doForm = {
- pc_id: rowData.pc_id,
- rent_end: dayjs(new Date(rowData.rent_end)).format("YYYY-MM-DD HH:mm:ss"),
- add_list: AddList,
- };
- const data = await rentingOutRentComputer(doForm);
- // console.log(data)
- if (data.code == 0) {
- visible_rentingOut.value = false;
- ElMessage.success(data.msg);
- getTableData();
- } else {
- // ElMessage.error(data.msg);
- }
- }
- // 拉起换编号弹窗
- async function switchReplaceNum(rowData) {
- replaceNumForm.value.pc_num_old = rowData.pc_num;
- replaceNumForm.value.shop_id = rowData.shop_id;
- replaceNumForm.value.shop_name = rowData.shop_name;
- if (visible_replaceNum.value == false) {
- visible_replaceNum.value = true;
- }
- }
- // 换编
- async function replaceNum(rowData) {
- let doForm = {
- pc_num_old: rowData.pc_num_old,
- pc_num_new: rowData.pc_num_new,
- shop_id: rowData.shop_id,
- };
- const data = await replaceNumRentComputer(doForm);
- // console.log(data)
- if (data.code == 0) {
- visible_replaceNum.value = false;
- ElMessage.success(data.msg);
- getTableData();
- } else {
- // ElMessage.error(data.msg);
- }
- }
- const downloadExcelTemplate = () => {
- downloadTemplate("RentComputerTemplate.xlsx");
- };
- // 删除/下架
- async function offShelf(rowData) {
- let message = "确定要下架编号为" + rowData.pc_num + "的租机吗?";
- if (rowData.is_expire != 1) {
- message = "机器未到期,确定强制下架编号为" + rowData.pc_num + "的租机吗?";
- }
- let doForm = {
- id: rowData.id,
- pc_num: rowData.pc_num,
- };
- // console.log(doForm);
- ElMessageBox.confirm(message, "租机下架", {
- dangerouslyUseHTMLString: true,
- type: "warning",
- })
- .then(async () => {
- const data = await offShelfRentComputer(doForm);
- if (data.code == 0) {
- ElMessage.success(data.msg);
- getTableData();
- } else {
- ElMessage.error(data.msg);
- }
- })
- .catch(() => null);
- }
- // 分页
- const handleSizeChange = (val) => {
- pageSize.value = val;
- getTableData();
- };
- const onReset = () => {
- searchInfo.value = {};
- };
- const handleCurrentChange = (val) => {
- page.value = val;
- getTableData();
- };
- // 排序
- const sortChange = ({ prop, order }) => {
- if (prop) {
- if (prop === "id") {
- prop = "id";
- }
- searchInfo.value.orderKey = toSQLLine(prop);
- searchInfo.value.desc = order === "descending";
- }
- getTableData();
- };
- // 搜索
- const onSubmit = () => {
- page.value = 1;
- pageSize.value = 20;
- if (typeof searchInfo.value.set_meal_id != "undefined") {
- searchInfo.value.set_meal_id = Number(searchInfo.value.set_meal_id);
- }
- if (typeof searchInfo.value.is_expire != "undefined") {
- searchInfo.value.is_expire = Number(searchInfo.value.is_expire);
- }
- if (typeof searchInfo.value.is_off_shelf != "undefined") {
- searchInfo.value.is_off_shelf = Number(searchInfo.value.is_off_shelf);
- }
- // console.log(searchInfo);
- getTableData();
- };
- // 查询
- const getTableData = async () => {
- loading.value = true;
- const table = await getRentComputerList({
- page: page.value,
- pageSize: pageSize.value,
- ...searchInfo.value,
- });
- if (table.code === 0) {
- tableData.value = table.data.list;
- total.value = table.data.total;
- page.value = table.data.page;
- pageSize.value = table.data.pageSize;
- getComputerNum();
- getSelectList();
- }
- await getIsExpireData();
- loading.value = false;
- };
- // 查询是否有到期
- const getIsExpireData = async () => {
- loading.value = true;
- tagExpire.value = false;
- const table = await getRentComputerList({
- page: 1,
- pageSize: 999,
- ...searchInfo.value,
- });
- // console.log(table.data.list)
- if (table.code === 0 && table.data.list != null) {
- for (const item of table.data.list) {
- if (item.is_expire >= 2) {
- ElMessageBox.alert("有租机即将到期,请注意续费!!!", "警告", {
- confirmButtonText: "好的",
- type: "warning",
- callback: (action) => {
- tagExpire.value = true;
- },
- });
- break;
- }
- }
- }
- };
- //获取下拉框list
- const getSelectList = async () => {
- //listRentComputerShopList
- const rentComputerShop = await listRentComputerShopList({
- page: 1,
- pageSize: 999,
- });
- let rentComputerShopList = [];
- const data = rentComputerShop.data.list;
- data.forEach((e) => {
- rentComputerShopList.push({ value: e.id, label: e.name });
- });
- shopOptions.value = rentComputerShopList;
- //listRentSetMealList
- const setMealShop = await listRentSetMealList({
- page: 1,
- pageSize: 999,
- });
- let setMealList = [];
- const data2 = setMealShop.data.list;
- data2.forEach((e) => {
- var priceStr = "";
- if (e.price_type == 0) {
- priceStr = "天卡(" + e.rent_price + "元)";
- } else if (e.price_type == 1) {
- priceStr = "周卡(" + e.rent_price + "元)";
- } else {
- priceStr = "月卡(" + e.rent_price + "元)";
- }
- setMealList.push({
- value: e.id,
- label: e.shop_name + "-" + e.name + "-" + priceStr,
- });
- });
- setMealOptions.value = setMealList;
- //游戏负责人列表===============================
- const directorRes = await getDirectorList();
- let directorList = [
- { value: "ALL", label: "所有机器" },
- // { value: "", label: "备用" },
- ];
- const data3 = directorRes.data.list;
- data3.forEach((e) => {
- directorList.push({ value: e.name, label: e.name });
- });
- directorOptions.value = directorList;
- };
- // 查询
- const getComputerNum = async () => {
- const table = await getRentComputerNum({ ...searchInfo.value });
- if (table.code === 0) {
- // console.log(table.data);
- computerNum.value = table.data;
- }
- };
- //拉起TD连接
- const linkTd = async (row) => {
- let todesk_id = row.todesk_id;
- let todesk_password = row.todesk_password;
- todesk_id = todesk_id.replace(/\s*/g, "");
- todesk_password = todesk_password.replace(/\s*/g, "");
- // console.log(todesk_id);
- // console.log(todesk_password);
- if (todesk_id == "" || todesk_password == "") {
- ElMessage({
- type: "error",
- message: "todesk账号密码不完整!",
- });
- } else {
- window.location.href =
- "ToDesk://connect&" + todesk_id + "&" + todesk_password;
- }
- };
- getTableData();
- // 批量操作
- const handleSelectionChange = (val) => {
- apis.value = val;
- };
- const dialogFormVisible = ref(false);
- // 弹窗相关
- const menuForm = ref(null);
- const checkFlag = ref(false);
- const initForm = () => {
- checkFlag.value = false;
- menuForm.value.resetFields();
- form.value = {
- id: 0,
- coding: "",
- describe: "",
- parent_id: "",
- };
- };
- const menuOption = ref([
- {
- id: "0",
- title: "根编号",
- },
- ]);
- const setOptions = () => {
- menuOption.value = [
- {
- id: "0",
- title: "根目录",
- },
- ];
- setMenuOptions(tableData.value, menuOption.value, false);
- };
- const setMenuOptions = (menuData, optionsData, disabled) => {
- menuData &&
- menuData.forEach((item) => {
- if (item.children && item.children.length) {
- const option = {
- ID: String(item.id),
- disabled: disabled || item.id === form.value.id,
- children: [],
- };
- setMenuOptions(
- item.children,
- option.children,
- disabled || item.id === form.value.id
- );
- optionsData.push(option);
- } else {
- const option = {
- ID: String(item.id),
- disabled: disabled || item.id === form.value.id,
- };
- optionsData.push(option);
- }
- });
- };
- const loadExcel = (res) => {
- if (res.code === 0) {
- ElMessage({
- type: "success",
- message: res.msg,
- });
- } else {
- ElMessage({
- type: "error",
- message: res.msg,
- showClose: true,
- });
- }
- getTableData();
- };
- // 添加菜单方法,id为 0则为添加根菜单
- const isEdit = ref(false);
- const dialogTitle = ref("新增租机");
- const addMenu = async (id) => {
- dialogTitle.value = "新增租机";
- form.value.parent_id = String(id);
- isEdit.value = false;
- setOptions();
- dialogFormVisible.value = true;
- getSelectList();
- };
- // 修改菜单方法
- const editMenu = async (id) => {
- dialogTitle.value = "编辑租机";
- const res = await getRentComputerById({ id });
- form.value = res.data;
- // console.log(form.value);
- if (form.value.is_off_shelf == 1) {
- form.value.is_off_shelf = true;
- } else {
- form.value.is_off_shelf = false;
- }
- isEdit.value = true;
- setOptions();
- dialogFormVisible.value = true;
- getSelectList();
- };
- const closeDialog = () => {
- initForm();
- dialogFormVisible.value = false;
- };
- // 批量删除菜单
- const deletesMenu = async () => {
- ElMessageBox.confirm("确定批量删除所选吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(async () => {
- const ids = apis.value.map((item) => item.id);
- // console.log(ids);
- const res = await deleteRentComputerByIds({ ids });
- if (res.code === 0) {
- ElMessage({
- type: "success",
- message: "删除成功!",
- });
- getTableData();
- }
- })
- .catch(() => {
- ElMessage({
- type: "info",
- message: "已取消删除",
- });
- });
- };
- // 删除菜单
- const deleteMenu = async (id) => {
- ElMessageBox.confirm("确定删除?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(async () => {
- // console.log(id);
- const res = await deleteRentComputerById({ id });
- if (res.code === 0) {
- ElMessage({
- type: "success",
- message: "删除成功!",
- });
- getTableData();
- }
- })
- .catch(() => {
- ElMessage({
- type: "info",
- message: "已取消删除",
- });
- });
- };
- const enterDialog = async () => {
- // console.log(form.value);
- menuForm.value.validate(async (valid) => {
- if (valid) {
- let res;
- form.value.id = Number(form.value.id);
- form.value.shop_id = Number(form.value.shop_id);
- form.value.set_meal_id = Number(form.value.set_meal_id);
- form.value.rent_duration = Number(form.value.rent_duration);
- form.value.rent_start = formatDate(form.value.rent_start);
- form.value.rent_end = formatDate(form.value.rent_end);
- form.value.is_expire = Number(form.value.is_expire);
- if (form.value.is_off_shelf == true) {
- form.value.is_off_shelf = 1;
- } else {
- form.value.is_off_shelf = 0;
- }
- if (isEdit.value) {
- res = await editRentComputer(form.value);
- } else {
- res = await addRentComputer(form.value);
- }
- if (res.code === 0) {
- ElMessage({
- type: "success",
- message: isEdit.value ? "编辑成功" : "添加成功!",
- });
- getTableData();
- } else {
- ElMessage({
- type: "error",
- message: res.message,
- });
- }
- initForm();
- dialogFormVisible.value = false;
- }
- });
- };
- </script>
- <style scoped lang="scss">
- .button-box {
- padding: 10px 20px;
- .el-button {
- float: right;
- }
- }
- .warning {
- color: #dc143c;
- }
- </style>
|