index.vue 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224
  1. <template>
  2. <div ref="appContainer" class="app-container">
  3. <div ref="myContainer" class="myContainer">
  4. <!-- 配方模板表 -->
  5. <div ref="template" class="template">
  6. <div class="recipeTemplate">
  7. <p>配方模板表</p>
  8. </div>
  9. <div class="search">
  10. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  11. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  14. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  15. </el-select>
  16. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="来源" class="filter-item" style="width: 120px;" clearable>
  17. <el-option v-for="item in sourceList" :key="item.id" :label="item.name" :value="item.id" />
  18. </el-select>
  19. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  21. </el-select>
  22. <div ref="selectInput" class="filter-item selectInput">
  23. <el-input v-model="table.getdataListParm.parammaps.all" type="text" placeholder="请点击选择搜索条件" class="Input" />
  24. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  25. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  26. <ul v-if="arrowUp" class="selectUl">
  27. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" clearable style="width: 245px;" /></li>
  28. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" clearable style="width: 245px;" /></li>
  29. <li />
  30. <!-- <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" clearable style="width: 245px;" /></li> -->
  31. <li>
  32. <div style="float: right;">
  33. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  34. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  35. </div>
  36. </li>
  37. </ul>
  38. </div>
  39. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  40. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  41. </div>
  42. <div class="operation">
  43. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  44. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  45. <el-button v-if="isRoleEdit" class="copy" icon="el-icon-copy-document" @click="handleCopy">复制</el-button>
  46. <el-button v-if="isRoleEdit" class="success" icon="el-icon-open" @click="handleTakeEffect">生效</el-button>
  47. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-turn-off" @click="handleDisable">禁用</el-button>
  48. <el-upload style="float: right;margin-right: 15px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  49. <el-button v-if="isRoleEdit" class="export" icon="el-icon-download" style="float: right;">导入</el-button>
  50. </el-upload>
  51. <el-dropdown style="float: right;">
  52. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  53. <el-dropdown-menu slot="dropdown">
  54. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  55. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  56. </el-dropdown-menu>
  57. </el-dropdown>
  58. <el-button class="export" style="float: right;" @click="handleRecipeRecord">配方记录</el-button>
  59. </div>
  60. <div ref="table" class="table">
  61. <el-table
  62. :key="table.tableKey"
  63. v-loading="table.listLoading"
  64. element-loading-text="给我一点时间"
  65. :data="table.list"
  66. border
  67. fit
  68. highlight-current-row
  69. style="width: 98%;"
  70. :row-style="rowStyle"
  71. :cell-style="cellStyle"
  72. class="elTable table-fixed"
  73. :height="myheight"
  74. @row-click="tableRowClick"
  75. @selection-change="handleSelectionChange"
  76. >
  77. <el-table-column type="selection" align="center" width="50" />
  78. <el-table-column label="序号" align="center" type="index" width="50px" />
  79. <el-table-column label="配方名称" min-width="90px" align="center">
  80. <template slot-scope="scope">
  81. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  82. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="配方编码" min-width="110px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.tcode }}</span>
  88. <!-- <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tcode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" /> -->
  89. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tcode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" disabled maxlength="32" style="width:98%;padding:10px 0;" />
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="配方颜色" min-width="70px" align="center">
  93. <template slot-scope="scope">
  94. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="牲畜类别" min-width="130px" align="center">
  98. <template slot-scope="scope">
  99. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  100. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  101. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  102. </el-select>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="配方类型" min-width="130px" align="center">
  106. <template slot-scope="scope">
  107. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  108. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  109. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  110. </el-select>
  111. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  112. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  113. </el-select>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="来源" min-width="90px" align="center">
  117. <template slot-scope="scope">
  118. <span>{{ scope.row.source }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column label="备注" min-width="90px" align="center">
  122. <template slot-scope="scope">
  123. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  124. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="版本号" min-width="90px" align="center">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.version }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="是否启用" min-width="90px" align="center">
  133. <template slot-scope="scope">
  134. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  138. <template slot-scope="{row}">
  139. <el-button v-if="row.NoEdit && isRoleEdit && ispastureuse==0" icon="el-icon-tickets" class="miniSuccess" @click="handleRowRecipeRecord(row)" />
  140. <span v-if="row.NoEdit && isRoleEdit && ispastureuse ==0" icon="el-icon-data-line" class="centerSpan">|</span>
  141. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  142. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  143. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  144. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  145. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  146. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  147. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  148. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  149. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  150. <span v-if="row.NoEdit && isRoleEdit && ispastureuse ==0" icon="el-icon-data-line" class="centerSpan">|</span>
  151. <el-button v-if="row.NoEdit && isRoleEdit && ispastureuse==0" icon="el-icon-data-line" class="miniSuccess" @click="handleFormulationEvaluation(row)" />
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. </div>
  156. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;margin-bottom: 10px;font-size: 14px;">共{{ table.total }}条</span>
  157. </div>
  158. <!-- 配方详情表 -->
  159. <div v-if="isDetail" ref="detail" class="detail">
  160. <div class="recipeTemplate">
  161. <p>配方详情表</p>
  162. </div>
  163. <div class="operation">
  164. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-plus" class="success" @click="handleCreate2">新增</el-button>
  165. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-delete" class="danger" @click="handleDelete2">删除</el-button>
  166. <el-button v-if="isRoleEdit" style="float: left;" class="success" icon="el-icon-takeaway-box" @click="handleSyntheticPremix">合成预混料</el-button>
  167. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  168. <div v-else style="float: left;margin-left: 10px;">
  169. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  170. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  171. </div>
  172. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  173. <el-input v-model="table2.getdataListParm.parammaps.all" type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  174. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  175. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  176. <ul v-if="arrowUp2" class="selectUl">
  177. <li>
  178. <a style="width: 130px;">饲料名称</a>
  179. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:190px;">
  180. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  181. </el-select>
  182. </li>
  183. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 190px;" /></li>
  184. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 190px;" /></li>
  185. <li>
  186. <a style="width: 130px;">搅拌延时</a>
  187. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:190px;" clearable>
  188. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  189. </el-select>
  190. </li>
  191. <li>
  192. <a style="width: 130px;">是否锁定牛头数比例</a>
  193. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:190px;" clearable>
  194. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  195. </el-select>
  196. </li>
  197. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 190px;" /></li>
  198. <li>
  199. <div style="float: right;">
  200. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  201. <el-button class="miniPrimary" @click="handleSearch2">搜索</el-button>
  202. </div>
  203. </li>
  204. </ul>
  205. </div>
  206. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  207. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  208. <el-button class="hide" @click="handleCloseTable2">隐藏</el-button>
  209. <el-button v-if="isEnlarge" class="hide2" @click="handleEnlarge">放大</el-button>
  210. <el-button v-else class="hide2" @click="handleNarrow">缩小</el-button>
  211. </div>
  212. <div v-if="isEnlarge" class="table2">
  213. <el-table
  214. id="table2"
  215. ref="table2"
  216. :key="table2.tableKey"
  217. v-loading="table2.listLoading"
  218. element-loading-text="给我一点时间"
  219. :data="table2.list"
  220. border
  221. fit
  222. highlight-current-row
  223. style="width: 98%;"
  224. :row-style="rowStyle"
  225. :cell-style="cellStyle"
  226. class="elTable"
  227. row-key="id"
  228. show-summary
  229. :max-height="220"
  230. :summary-method="getSummaries"
  231. @selection-change="handleSelectionChange2"
  232. @cell-dblclick="celldblclick"
  233. >
  234. <el-table-column type="selection" width="50" />
  235. <el-table-column label="序号" align="center" type="index" width="50px" />
  236. <el-table-column label="饲料组" min-width="120px" align="center">
  237. <template slot-scope="scope">
  238. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  239. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="饲料名称" min-width="120px" align="center">
  243. <template slot-scope="scope">
  244. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  245. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  246. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  247. </el-select>
  248. </template>
  249. </el-table-column>
  250. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  251. <template slot-scope="scope">
  252. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  253. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.001" type="number" style="width:95%;padding:10px 0;" />
  254. </template>
  255. </el-table-column>
  256. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  257. <template slot-scope="scope">
  258. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  259. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  260. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  261. </el-select>
  262. </template>
  263. </el-table-column>
  264. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  265. <template slot-scope="scope">
  266. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  267. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  268. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  269. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  270. </el-select>
  271. </template>
  272. </el-table-column>
  273. <el-table-column label="顺序" min-width="70px" align="center">
  274. <template slot-scope="scope">
  275. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  276. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  277. </template>
  278. </el-table-column>
  279. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  280. <template slot-scope="{row}">
  281. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  282. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  283. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  284. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  285. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  286. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  287. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  288. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  289. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  290. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  291. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  292. </template>
  293. </el-table-column>
  294. </el-table>
  295. </div>
  296. <div v-else class="table2">
  297. <el-table
  298. id="table2"
  299. ref="mytable2"
  300. :key="table2.tableKey"
  301. v-loading="table2.listLoading"
  302. element-loading-text="给我一点时间"
  303. :data="table2.list"
  304. border
  305. fit
  306. highlight-current-row
  307. style="width: 98%;"
  308. :row-style="rowStyle"
  309. :cell-style="cellStyle"
  310. class="elTable"
  311. row-key="id"
  312. show-summary
  313. :max-height="enlargeHeight"
  314. :summary-method="getSummaries"
  315. @selection-change="handleSelectionChange2"
  316. @cell-dblclick="celldblclick"
  317. >
  318. <el-table-column type="selection" width="50" />
  319. <el-table-column label="序号" align="center" type="index" width="50px" />
  320. <el-table-column label="饲料组" min-width="120px" align="center">
  321. <template slot-scope="scope">
  322. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  323. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  324. </template>
  325. </el-table-column>
  326. <el-table-column label="饲料名称" min-width="120px" align="center">
  327. <template slot-scope="scope">
  328. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  329. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  330. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  331. </el-select>
  332. </template>
  333. </el-table-column>
  334. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  335. <template slot-scope="scope">
  336. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  337. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  338. </template>
  339. </el-table-column>
  340. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  341. <template slot-scope="scope">
  342. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  343. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  344. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  345. </el-select>
  346. </template>
  347. </el-table-column>
  348. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  349. <template slot-scope="scope">
  350. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  351. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  352. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  353. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  354. </el-select>
  355. </template>
  356. </el-table-column>
  357. <el-table-column label="顺序" min-width="70px" align="center">
  358. <template slot-scope="scope">
  359. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  360. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  361. </template>
  362. </el-table-column>
  363. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  364. <template slot-scope="{row}">
  365. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  366. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  367. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  368. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  369. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  370. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  371. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  372. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  373. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  374. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  375. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  376. </template>
  377. </el-table-column>
  378. </el-table>
  379. </div>
  380. </div>
  381. </div>
  382. <!-- 配方模板表 -->
  383. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  384. <template slot="title">
  385. <div class="avue-crud__dialog__header">
  386. <span class="el-dialog__title">
  387. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  388. {{ textMap[template.dialogStatus] }}
  389. </span>
  390. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  391. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  392. <svg-icon v-else icon-class="fullscreen" />
  393. </div>
  394. </div>
  395. </template>
  396. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 0px;overflow-x: hidden;">
  397. <div ref="templateDialog" class="templateDialog">
  398. <div class="recipeTemplate">
  399. <p>配方模板表</p>
  400. </div>
  401. <div class="operation1">
  402. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  403. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  404. </div>
  405. <div class="search">
  406. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  407. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  408. </el-select>
  409. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  410. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  411. </el-select>
  412. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="margin-left:10px;width: 120px;" clearable>
  413. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  414. </el-select>
  415. <div ref="selectInput" class="filter-item selectInput">
  416. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  417. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  418. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  419. <ul v-if="arrowUp" class="selectUl">
  420. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  421. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  422. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  423. <li>
  424. <div style="float: right;">
  425. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  426. <el-button class="miniPrimary" @click="handleDialogSearch">搜索</el-button>
  427. </div>
  428. </li>
  429. </ul>
  430. </div>
  431. <el-button class="successBorder" @click="handleDialogSearch" style="margin-left:10px;">查询</el-button>
  432. <el-button class="successBorder" @click="handleDialogRefresh" style="margin-left:10px;">重置</el-button>
  433. </div>
  434. <div class="table">
  435. <el-table
  436. :key="template.table.tableKey"
  437. v-loading="template.table.listLoading"
  438. element-loading-text="给我一点时间"
  439. :data="template.table.list"
  440. border
  441. fit
  442. highlight-current-row
  443. style="width: 98%;"
  444. :row-style="rowStyle"
  445. :height="myheight2"
  446. :cell-style="cellStyle"
  447. class="elTable table-fixed"
  448. @row-click="tableRowClickDialog"
  449. >
  450. <el-table-column v-if="template.dialogStatus == 'RecipeRecord'" label="序号" align="center" type="index" width="50px" />
  451. <el-table-column v-else label="序号" align="center" type="index" width="50px">
  452. <template slot-scope="scope">
  453. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  454. </template>
  455. </el-table-column>
  456. <el-table-column label="配方名称" min-width="130px" align="center">
  457. <template slot-scope="scope">
  458. <span>{{ scope.row.tname }}</span>
  459. </template>
  460. </el-table-column>
  461. <el-table-column label="配方编码" min-width="90px" align="center">
  462. <template slot-scope="scope">
  463. <span>{{ scope.row.tcode }}</span>
  464. </template>
  465. </el-table-column>
  466. <el-table-column label="配方颜色" min-width="110px" align="center">
  467. <template slot-scope="scope">
  468. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" />
  469. </template>
  470. </el-table-column>
  471. <el-table-column label="牲畜类别" min-width="110px" align="center">
  472. <template slot-scope="scope">
  473. <span>{{ scope.row.ccname }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column label="配方类型" min-width="110px" align="center">
  477. <template slot-scope="scope">
  478. <span>{{ scope.row.fttype }}</span>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="来源" min-width="90px" align="center">
  482. <template slot-scope="scope">
  483. <span>{{ scope.row.source }}</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="备注" min-width="90px" align="center">
  487. <template slot-scope="scope">
  488. <span>{{ scope.row.remark }}</span>
  489. </template>
  490. </el-table-column>
  491. <el-table-column label="版本号" min-width="90px" align="center">
  492. <template slot-scope="scope">
  493. <span>{{ scope.row.version }}</span>
  494. </template>
  495. </el-table-column>
  496. <el-table-column label="版本时间" min-width="90px" align="center">
  497. <template slot-scope="scope">
  498. <span>{{ scope.row.versiontime }}</span>
  499. </template>
  500. </el-table-column>
  501. <el-table-column label="是否启用" min-width="90px" align="center">
  502. <template slot-scope="scope">
  503. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  504. </template>
  505. </el-table-column>
  506. </el-table>
  507. </div>
  508. </div>
  509. <div v-if="isDetailDialog" id="detailDialog2" ref="detailDialog2" class="detailDialog" style="margin-top: 30px;height: 200px;overflow-y: auto;overflow-x: hidden;">
  510. <div class="recipeTemplate">
  511. <p>配方详情表</p>
  512. </div>
  513. <div class="operation">
  514. <div ref="selectInput2" class="filter-item selectInput">
  515. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  516. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  517. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  518. <ul v-if="arrowUp2" class="selectUl">
  519. <li>
  520. <a style="width: 130px;">饲料名称</a>
  521. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  522. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  523. </el-select>
  524. </li>
  525. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  526. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  527. <li>
  528. <a style="width: 130px;">搅拌延时</a>
  529. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  530. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  531. </el-select>
  532. </li>
  533. <li>
  534. <a style="width: 130px;">是否锁定牛头数比例</a>
  535. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  536. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  537. </el-select>
  538. </li>
  539. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  540. <li>
  541. <div style="float: right;">
  542. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  543. <el-button class="miniPrimary" @click="handleDialogSearch2">搜索</el-button>
  544. </div>
  545. </li>
  546. </ul>
  547. </div>
  548. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  549. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  550. <el-button class="hide" @click="handleDialogCloseTable2">隐藏</el-button>
  551. </div>
  552. <div class="table2">
  553. <el-table
  554. id="templateTable2"
  555. :key="template.table2.tableKey"
  556. v-loading="template.table2.listLoading"
  557. element-loading-text="给我一点时间"
  558. :data="template.table2.list"
  559. border
  560. fit
  561. highlight-current-row
  562. style="width: 98%;"
  563. :summary-method="getTemplateTable2Summaries"
  564. show-summary
  565. :row-style="rowStyle"
  566. :cell-style="cellStyle"
  567. class="elTable table-fixed"
  568. row-key="id"
  569. >
  570. <el-table-column label="饲料组" min-width="130px" align="center">
  571. <template slot-scope="scope">
  572. <span>{{ scope.row.feedgroup }}</span>
  573. </template>
  574. </el-table-column>
  575. <el-table-column label="饲料名称" min-width="130px" align="center">
  576. <template slot-scope="scope">
  577. <span>{{ scope.row.fname }}</span>
  578. </template>
  579. </el-table-column>
  580. <el-table-column label="重量(KG)" prop="fweight" min-width="200px" align="center">
  581. <template slot-scope="scope">
  582. <span>{{ scope.row.fweight }}</span>
  583. </template>
  584. </el-table-column>
  585. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  586. <template slot-scope="scope">
  587. <span>{{ scope.row.autosecondname }}</span>
  588. </template>
  589. </el-table-column>
  590. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  591. <template slot-scope="scope">
  592. <span v-if="scope.row.islockcount == '0'">否</span>
  593. <span v-if="scope.row.islockcount == '1'">是</span>
  594. </template>
  595. </el-table-column>
  596. <el-table-column label="顺序" min-width="130px" align="center">
  597. <template slot-scope="scope">
  598. <span>{{ scope.row.sort }}</span>
  599. </template>
  600. </el-table-column>
  601. </el-table>
  602. </div>
  603. </div>
  604. </div>
  605. <div slot="footer" class="dialog-footer">
  606. <el-button class="cancelClose cancelClose1" @click="template.dialogFormVisible = false; ">关闭</el-button>
  607. </div>
  608. </el-dialog>
  609. <!-- 合成预混料 -->
  610. <el-dialog :fullscreen="dialogFull" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  611. <template slot="title">
  612. <div class="avue-crud__dialog__header">
  613. <span class="el-dialog__title">
  614. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  615. {{ textMap[detail.dialogStatus] }}
  616. </span>
  617. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  618. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  619. <svg-icon v-else icon-class="fullscreen" />
  620. </div>
  621. </div>
  622. </template>
  623. <div class="detailDialog">
  624. <h2>饲料</h2>
  625. <div class="table1">
  626. <el-table
  627. :key="detail.tableKey"
  628. v-loading="detail.listLoading"
  629. element-loading-text="给我一点时间"
  630. :data="detail.list"
  631. fit
  632. highlight-current-row
  633. style="width: 100%;"
  634. :row-style="rowStyle"
  635. :cell-style="cellStyle"
  636. class="elTable table-fixed"
  637. show-summary
  638. >
  639. <el-table-column label="序号" align="center" type="index" width="50px" />
  640. <el-table-column label="饲料名称" min-width="130px" align="center">
  641. <template slot-scope="scope">
  642. <span>{{ scope.row.fname }}</span>
  643. </template>
  644. </el-table-column>
  645. <el-table-column prop="fweight" label="重量(KG)" />
  646. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  647. <template slot-scope="scope">
  648. <span>{{ scope.row.autosecond }}</span>
  649. </template>
  650. </el-table-column>
  651. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  652. <template slot-scope="scope">
  653. <span v-if="scope.row.islockcount == '0'">否</span>
  654. <span v-if="scope.row.islockcount == '1'">是</span>
  655. </template>
  656. </el-table-column>
  657. <el-table-column label="顺序" min-width="110px" align="center">
  658. <template slot-scope="scope">
  659. <span>{{ scope.row.sort }}</span>
  660. </template>
  661. </el-table-column>
  662. </el-table>
  663. </div>
  664. <h2>合成预混料</h2>
  665. <div class="table2" style="margin-bottom: 50px;">
  666. <el-table
  667. :key="detail.tableKey2"
  668. v-loading="detail.listLoading2"
  669. element-loading-text="给我一点时间"
  670. :data="detail.list2"
  671. border
  672. fit
  673. highlight-current-row
  674. style="width: 100%;"
  675. :row-style="rowStyle"
  676. :cell-style="cellStyle"
  677. class="elTable table-fixed"
  678. >
  679. <el-table-column label="配方名称" min-width="130px" align="center">
  680. <template slot-scope="scope">
  681. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  682. </template>
  683. </el-table-column>
  684. <el-table-column label="配方颜色" min-width="130px" align="center">
  685. <template slot-scope="scope">
  686. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="detail.disabled" />
  687. </template>
  688. </el-table-column>
  689. <el-table-column label="牲畜类别" min-width="130px" align="center">
  690. <template slot-scope="scope">
  691. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  692. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  693. </el-select>
  694. </template>
  695. </el-table-column>
  696. <el-table-column label="配方类型" min-width="110px" align="center">
  697. <template slot-scope="scope">
  698. <span>{{ scope.row.fttype }}</span>
  699. </template>
  700. </el-table-column>
  701. <el-table-column label="来源" min-width="110px" align="center">
  702. <template slot-scope="scope">
  703. <span>{{ scope.row.source }}</span>
  704. </template>
  705. </el-table-column>
  706. <el-table-column label="备注" min-width="130px" align="center">
  707. <template slot-scope="scope">
  708. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  709. </template>
  710. </el-table-column>
  711. <el-table-column label="是否启用" min-width="130px" align="center">
  712. <template slot-scope="scope">
  713. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  714. </template>
  715. </el-table-column>
  716. </el-table>
  717. </div>
  718. <div slot="footer" class="dialog-footer">
  719. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  720. <el-button class="save" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  721. </div>
  722. </div>
  723. </el-dialog>
  724. <!-- 历史记录 -->
  725. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  726. <div class="historyRecord">
  727. <keep-alive>
  728. <component :is="historyRecord.myComponent" ref="historyRecord" />
  729. </keep-alive>
  730. </div>
  731. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  732. <el-button class="cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  733. </div>
  734. </el-dialog>
  735. <!-- 行内配方记录 -->
  736. <el-dialog :title="textMap[rowRecipeRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="rowRecipeRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  737. <div class="rowRecipeRecord">
  738. <div class="search">
  739. <el-date-picker ref="inputDatetime" v-model="rowRecipeRecord.getdataListParm.parammaps.inputDatetime" class="filter-item inputDatetime" type="daterange" style="width: 250px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
  740. <el-button class="successBorder" @click="handleRowRecipeRecordSearch">查询</el-button>
  741. </div>
  742. <div class="table">
  743. <el-table
  744. :key="rowRecipeRecord.tableKey"
  745. v-loading="rowRecipeRecord.listLoading"
  746. element-loading-text="给我一点时间"
  747. :data="rowRecipeRecord.list"
  748. border
  749. highlight-current-row
  750. style="width: 100%;"
  751. :row-style="rowStyle"
  752. :cell-style="cellStyle"
  753. class="elTable table-fixed"
  754. >
  755. <el-table-column label="序号" align="center" type="index" width="50px">
  756. <template slot-scope="scope">
  757. <span>{{ scope.$index + (rowRecipeRecord.pageNum-1) * rowRecipeRecord.pageSize + 1 }}</span>
  758. </template>
  759. </el-table-column>
  760. <!-- <el-table-column label="序号" width="60px" align="center" prop="sort" /> -->
  761. <el-table-column label="修改时间" width="100px" align="center" prop="datetime1" />
  762. <el-table-column label="饲料名称(单位:kg)" min-width="800px" align="center">
  763. <template slot-scope="scope">
  764. <div v-for="element in scope.row.arrList" :key="element.name" class="list-group-item2 item" style="width:150px;float: left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin: 5px 5px;padding: 0;height: 30px;">
  765. <el-tooltip v-if="element.change== 'red'" placement="top" :open-delay="1000">
  766. <div slot="content">{{ element.name }}( {{ element.weight }} / {{ element.Eweight }} )</div>
  767. <span :style="{'color':element.change}" style="display: block;height:30px;line-height: 30px;">
  768. {{ element.name }}( {{ element.weight }} / {{ element.Eweight }} )
  769. </span>
  770. </el-tooltip>
  771. <el-tooltip v-else placement="top" :open-delay="1000">
  772. <div slot="content">{{ element.name }}( {{ element.weight }})</div>
  773. <span :style="{'color':element.change}" style="display: block;height:30px;line-height: 30px;">
  774. {{ element.name }}( {{ element.weight }})
  775. </span>
  776. </el-tooltip>
  777. </div>
  778. </template>
  779. </el-table-column>
  780. </el-table>
  781. <pagination v-show="rowRecipeRecord.total>=0" :total="rowRecipeRecord.total" :page.sync="rowRecipeRecord.getdataListParm.offset" :limit.sync="rowRecipeRecord.getdataListParm.pagecount" @pagination="getRowRecipeRecordList()" />
  782. </div>
  783. </div>
  784. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  785. <el-button class="cancelClose1" @click="rowRecipeRecord.dialogFormVisible = false; ">关闭</el-button>
  786. </div>
  787. </el-dialog>
  788. </div>
  789. </template>
  790. <script>
  791. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, checkButtons, postJson, ExecDataByConfig, formatNum } from '@/api/common'
  792. import Sortable from 'sortablejs'
  793. import { MessageBox } from 'element-ui'
  794. import Cookies from 'js-cookie'
  795. import { json2excel } from '@/utils/index.js'
  796. import axios from 'axios'
  797. import { getToken } from '@/utils/auth'
  798. import { parseTime } from '@/utils/index.js'
  799. import Pagination from '@/components/Pagination'
  800. export default {
  801. name: 'RecipeTemplate',
  802. components: { Pagination },
  803. data() {
  804. return {
  805. dialogFull: false,
  806. predefineColors: [
  807. '#E57373', '#F06292', '#BA68C8', '#9575CD', '#7986CB', '#64B5F6', '#4FC3F7', '#4DD0E1', '#4DB6AC', '#81C784', '#AED581', '#DCE775', '#FFF176', '#FFD54F', '#FFB74D', '#FF8A65', '#A1887F', '#E0E0E0', '#90A4AE'
  808. ],
  809. isRoleEdit: [],
  810. myheight: document.documentElement.clientHeight - 265,
  811. requestParams: [
  812. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  813. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  814. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  815. ],
  816. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  817. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  818. livestockTypeList: [], // 牲畜类别
  819. formulaTypeList: [], // 配方类型
  820. feedNameList: [], // 饲料名称
  821. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  822. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  823. arrowDown: true,
  824. arrowUp: false,
  825. ispastureuse: Cookies.get('ispastureuse'),
  826. table: {
  827. getdataListParm: {
  828. name: 'getFTList',
  829. page: 1,
  830. offset: 1,
  831. pagecount: '',
  832. returntype: 'Map',
  833. parammaps: {
  834. pastureid: Cookies.get('pastureid'),
  835. tname: '',
  836. ccid: '',
  837. ccname: '',
  838. fttypeid: '',
  839. fttype: '',
  840. remark: '',
  841. enable: '',
  842. source: ''
  843. }
  844. },
  845. tableKey: 0,
  846. list: [],
  847. total: 0,
  848. listLoading: true,
  849. temp: {}
  850. },
  851. lockCount: {
  852. getdataListParm: {
  853. name: 'getSysoptEnable',
  854. page: 1,
  855. offset: 1,
  856. pagecount: 30,
  857. returntype: 'Map',
  858. parammaps: {
  859. pastureid: Cookies.get('pastureid'),
  860. inforname: 'isLockCount'
  861. }
  862. },
  863. isLockCount: false // 是否显示是否锁定牛头数比例
  864. },
  865. isDetail: false,
  866. arrowDown2: true,
  867. arrowUp2: false,
  868. table2: {
  869. getDryweightParm: {
  870. name: 'getFTdryweight',
  871. page: 1,
  872. offset: 1,
  873. pagecount: 10,
  874. returntype: 'Map',
  875. parammaps: {
  876. pastureid: '',
  877. ftid: ''
  878. }
  879. },
  880. dryweight: '',
  881. getdataListParm: {
  882. name: 'getFTdetailList',
  883. page: 1,
  884. offset: 1,
  885. pagecount: '',
  886. returntype: 'Map',
  887. parammaps: {
  888. pastureid: Cookies.get('pastureid'),
  889. fname: '',
  890. feedgroup: '',
  891. fweight: '',
  892. autosecondname: '',
  893. islockcount: '',
  894. sort: ''
  895. }
  896. },
  897. tableKey: 0,
  898. list: [],
  899. total: 0,
  900. listLoading: true,
  901. temp: {},
  902. updateList: {}
  903. },
  904. isDetailDialog: false,
  905. template: {
  906. dialogFormVisible: false,
  907. dialogStatus: '',
  908. table: {
  909. getdataListParm: {
  910. name: 'getFTListDate',
  911. page: 1,
  912. offset: 1,
  913. pagecount: '',
  914. returntype: 'Map',
  915. parammaps: {
  916. pastureid: Cookies.get('pastureid'),
  917. tname: '',
  918. ccid: '',
  919. ccname: '',
  920. fttype: '',
  921. remark: '',
  922. enable: '',
  923. date: '',
  924. source: ''
  925. }
  926. },
  927. tableKey: 0,
  928. total: 0,
  929. listLoading: true,
  930. list: []
  931. },
  932. table2: {
  933. getdataListParm: {
  934. name: 'getFTdetailListDate',
  935. page: 1,
  936. offset: 1,
  937. pagecount: 10,
  938. returntype: 'Map',
  939. parammaps: {
  940. pastureid: Cookies.get('pastureid'),
  941. fname: '',
  942. fweight: '',
  943. islockcount: '',
  944. sort: '',
  945. feedgroup: '',
  946. autosecondname: ''
  947. }
  948. },
  949. tableKey: 0,
  950. total: 0,
  951. listLoading: true,
  952. list: []
  953. },
  954. // 历史日期
  955. getdataDateParm: {
  956. name: 'getFTMaxDate',
  957. page: 1,
  958. offset: 1,
  959. pagecount: 10,
  960. returntype: 'Map',
  961. parammaps: {
  962. pastureid: Cookies.get('pastureid')
  963. }
  964. }
  965. },
  966. isOrder: true,
  967. detail: {
  968. dialogFormVisible: false,
  969. dialogStatus: '',
  970. tableKey: 0,
  971. total: 0,
  972. listLoading: true,
  973. list: [],
  974. tableKey2: 0,
  975. total2: 0,
  976. listLoading2: false,
  977. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  978. getdataListParm: {
  979. name: 'getFTDetailCompare',
  980. page: 1,
  981. offset: 1,
  982. pagecount: 10,
  983. returntype: 'Map',
  984. parammaps: {}
  985. },
  986. list3: [],
  987. disabled: false,
  988. getdataListParm2: {
  989. name: 'getFTCompare',
  990. page: 1,
  991. offset: 1,
  992. pagecount: 10,
  993. returntype: 'Map',
  994. parammaps: {}
  995. }
  996. },
  997. selectList: [],
  998. selectList2: [],
  999. textMap: {
  1000. RecipeRecord: '配方记录',
  1001. SyntheticPremix: '合成预混料',
  1002. historyRecord: '历史记录',
  1003. detail: '饲料详情',
  1004. rowRecipeRecordTxt: '配方修改记录'
  1005. },
  1006. requestParam: {},
  1007. requestParam2: {},
  1008. download: {
  1009. getdataListParm: {
  1010. name: 'getFTList',
  1011. page: 1,
  1012. offset: 1,
  1013. pagecount: 0,
  1014. returntype: 'Map',
  1015. parammaps: {
  1016. pastureid: Cookies.get('pastureid'),
  1017. tname: '',
  1018. ccid: '',
  1019. ccname: '',
  1020. fttypeid: '',
  1021. fttype: '',
  1022. remark: '',
  1023. enable: ''
  1024. }
  1025. },
  1026. list: []
  1027. },
  1028. historyRecord: {
  1029. dialogStatus: '',
  1030. dialogFormVisible: false
  1031. },
  1032. isokDisable: false,
  1033. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  1034. cellStyle: { padding: 0 + 'px' },
  1035. dropState: false,
  1036. myheight2: 0,
  1037. height: 0,
  1038. rowRecipeRecord: {
  1039. dialogStatus: '',
  1040. dialogFormVisible: false,
  1041. getdataListParm: {
  1042. name: 'getFitHistory1', 'name1': 'getFitHistory2', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  1043. parammaps: { inputDatetime: '', pastureid: '', fitid: '' }
  1044. },
  1045. tableKey: 0, total: 0, listLoading: true, list: []
  1046. },
  1047. isEnlarge: true,
  1048. // enlargeHeight: document.documentElement.clientHeight - 85 - 165 + 50,
  1049. enlargeHeight: document.documentElement.clientHeight - 85 - 165 + 50,
  1050. getTcodeParm: {
  1051. name: 'getTcode', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  1052. parammaps: { pastureid: '', fttypeid: '' }
  1053. },
  1054. sourceList: [{ id: '0', name: '自定义' }, { id: '1', name: '集团下发未调整' }, { id: '2', name: '集团下发有调整' }, { id: '3', name: '导入' }]
  1055. }
  1056. },
  1057. computed: {
  1058. // 设置请求头
  1059. headers() {
  1060. return {
  1061. token: getToken()
  1062. }
  1063. },
  1064. uploadData() {
  1065. return {
  1066. name: 'checkfttype,checkbigcowclass,checkFeed,insertFTUpload,insertFTdetailUpload',
  1067. importParams: '配方名称,牲畜类别,配方类型,备注,饲料组,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  1068. sheetname: 'Sheet1',
  1069. // 登录牧场
  1070. pastureid: Cookies.get('pastureid'),
  1071. // 日期参数
  1072. dateParams: '',
  1073. // 必填参数
  1074. requiredParams: '配方名称,牲畜类别,配方类型,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  1075. // 为数值的参数
  1076. numParams: '重量(kg),搅拌延时(min)'
  1077. }
  1078. },
  1079. // 设置上传地址
  1080. uploadExcelUrl() {
  1081. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  1082. }
  1083. },
  1084. mounted() {
  1085. document.addEventListener('click', (e) => {
  1086. if (this.$refs.selectInput !== undefined) {
  1087. if (!this.$refs.selectInput.contains(e.target)) {
  1088. this.arrowDown = true
  1089. this.arrowUp = false
  1090. } else {
  1091. this.arrowDown = false
  1092. this.arrowUp = true
  1093. }
  1094. }
  1095. if (this.$refs.selectInput2 !== undefined) {
  1096. if (!this.$refs.selectInput2.contains(e.target)) {
  1097. this.arrowDown2 = true
  1098. this.arrowUp2 = false
  1099. } else {
  1100. this.arrowDown2 = false
  1101. this.arrowUp2 = true
  1102. }
  1103. }
  1104. })
  1105. },
  1106. created() {
  1107. this.getList()
  1108. this.getButtons()
  1109. this.getDownList()
  1110. this.getIsLockCount()
  1111. },
  1112. methods: {
  1113. getButtons() {
  1114. const Edit = 'FormulationEvaluation'
  1115. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  1116. this.isRoleEdit = isRoleEdit
  1117. },
  1118. getSummaries(param) {
  1119. const { columns, data } = param
  1120. const sums = []
  1121. columns.forEach((column, index) => {
  1122. if (index === 0) {
  1123. sums[index] = '合计'
  1124. return
  1125. }
  1126. if (column.property !== undefined) {
  1127. // 加了prop属性的el-table-column 才能找到column.property
  1128. const values = data.map(item => Number(item[column.property]))
  1129. if (!values.every(value => isNaN(value))) {
  1130. sums[index] = values.reduce((prev, curr) => {
  1131. const value = Number(curr)
  1132. if (!isNaN(value)) {
  1133. return prev + curr // 多行相加
  1134. } else {
  1135. return prev
  1136. }
  1137. }, 0)
  1138. sums[index] = sums[index].toFixed(3) + '(干物质量:' + this.table2.dryweight + ')'
  1139. } else {
  1140. sums[index] = ''
  1141. }
  1142. }
  1143. })
  1144. // console.log(sums, 'sums[index]')
  1145. return sums
  1146. },
  1147. getDryWeight() {
  1148. GetDataByName(this.table2.getDryweightParm).then(response => {
  1149. console.log('干物质数据', response.data.list)
  1150. if (response.data.list[0].dryweight !== undefined) {
  1151. this.table2.dryweight = response.data.list[0].dryweight
  1152. } else {
  1153. this.table2.dryweight = ''
  1154. }
  1155. })
  1156. },
  1157. getTemplateTable2Summaries(param) {
  1158. const { columns, data } = param
  1159. const sums = []
  1160. columns.forEach((column, index) => {
  1161. if (index === 0) {
  1162. sums[index] = '合计'
  1163. return
  1164. }
  1165. const values = data.map(item => Number(item[column.property]))
  1166. if (!values.every(value => isNaN(value))) {
  1167. sums[index] = values.reduce((prev, curr) => {
  1168. const value = Number(curr)
  1169. if (!isNaN(value)) {
  1170. return prev + curr
  1171. } else {
  1172. return prev
  1173. }
  1174. }, 0)
  1175. // 后台待发
  1176. sums[index] += '(干物质量:' + this.template.table2.getdataListParm.parammaps.dryweight + ')'
  1177. } else {
  1178. sums[index] = ''
  1179. }
  1180. })
  1181. return sums
  1182. },
  1183. getDownList() {
  1184. GetDataByNames(this.requestParams).then(response => {
  1185. this.livestockTypeList = response.data.getDictByName.list
  1186. this.formulaTypeList = response.data.getDictByName2.list
  1187. this.feedNameList = response.data.getFeedAndPre.list
  1188. })
  1189. },
  1190. // -------------------模板-----------------------------
  1191. getList() {
  1192. this.table.listLoading = true
  1193. GetDataByName(this.table.getdataListParm).then(response => {
  1194. console.log('配方模板table数据', response.data.list)
  1195. if (response.data.list !== null) {
  1196. for (let i = 0; i < response.data.list.length; i++) {
  1197. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1198. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1199. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1200. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1201. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1202. }
  1203. this.table.list = response.data.list
  1204. this.table.pageNum = response.data.pageNum
  1205. this.table.pageSize = response.data.pageSize
  1206. this.table.total = response.data.total
  1207. } else {
  1208. this.table.list = []
  1209. this.isDetail = false
  1210. }
  1211. setTimeout(() => {
  1212. this.table.listLoading = false
  1213. }, 100)
  1214. })
  1215. },
  1216. getList3() {
  1217. this.table.listLoading = true
  1218. GetDataByName(this.table.getdataListParm).then(response => {
  1219. console.log('table数据', response.data.list)
  1220. if (response.data.list !== null) {
  1221. for (let i = 0; i < response.data.list.length; i++) {
  1222. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1223. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1224. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1225. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1226. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1227. }
  1228. this.table.list = response.data.list
  1229. this.table.pageNum = response.data.pageNum
  1230. this.table.pageSize = response.data.pageSize
  1231. this.table.total = response.data.total
  1232. } else {
  1233. this.table.list = []
  1234. this.isDetail = false
  1235. }
  1236. setTimeout(() => {
  1237. this.table.listLoading = false
  1238. }, 100)
  1239. })
  1240. },
  1241. handleSearch() {
  1242. console.log('点击了查询')
  1243. this.table.getdataListParm.offset = 1
  1244. this.getList()
  1245. this.table.getdataListParm.parammaps.all = ''
  1246. var obj = {}
  1247. obj.tname = this.table.getdataListParm.parammaps.tname
  1248. obj.remark = this.table.getdataListParm.parammaps.remark
  1249. // obj.source = this.table.getdataListParm.parammaps.source
  1250. Object.getOwnPropertyNames(obj).forEach((key) => {
  1251. console.log(key, obj[key])
  1252. if (obj[key] !== '') {
  1253. this.table.getdataListParm.parammaps.all += obj[key] + '/'
  1254. }
  1255. })
  1256. if (this.table.getdataListParm.parammaps.all.charAt(this.table.getdataListParm.parammaps.all.length - 1) == '/') {
  1257. this.table.getdataListParm.parammaps.all = this.table.getdataListParm.parammaps.all.slice(0, this.table.getdataListParm.parammaps.all.length - 1)
  1258. }
  1259. this.arrowDown = true
  1260. this.arrowUp = false
  1261. },
  1262. handleRefresh() {
  1263. console.log('点击了重置')
  1264. this.table.getdataListParm.offset = 1
  1265. this.table.getdataListParm.parammaps.ccid = ''
  1266. this.table.getdataListParm.parammaps.ccname = ''
  1267. this.table.getdataListParm.parammaps.fttype = ''
  1268. this.table.getdataListParm.parammaps.tname = ''
  1269. this.table.getdataListParm.parammaps.remark = ''
  1270. this.table.getdataListParm.parammaps.enable = ''
  1271. this.table.getdataListParm.parammaps.source = ''
  1272. this.table.getdataListParm.parammaps.all = ''
  1273. this.getList()
  1274. },
  1275. // 模板新增
  1276. handleCreate() {
  1277. // 编辑true/不可编辑false
  1278. // 新增操true,编辑false,编辑保存false
  1279. for (let i = 0; i < this.table.list.length; i++) {
  1280. if (this.table.list[i].Edit === true) {
  1281. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1282. return false
  1283. }
  1284. }
  1285. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', tcode: '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  1286. console.log('点击了新增this.table.list====>', this.table.list)
  1287. this.table.temp = this.table.list[0]
  1288. this.getTcodeList()
  1289. },
  1290. getTcodeList() {
  1291. this.getTcodeParm.parammaps.pastureid = Cookies.get('pastureid')
  1292. console.log(this.table.temp, 'this.table.temp')
  1293. GetDataByName(this.getTcodeParm).then(response => {
  1294. if (response.data.list !== null) {
  1295. this.table.temp.tcode = response.data.list[0].tcode
  1296. } else {
  1297. this.table.temp.tcode = ''
  1298. }
  1299. })
  1300. },
  1301. // 畜生类别
  1302. changeLivestockType(item) {
  1303. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1304. },
  1305. // 配方类型
  1306. changeFormulaType(item) {
  1307. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  1308. },
  1309. createData(row) {
  1310. console.log('点击了新增保存', row)
  1311. this.table.temp.tname = row.tname
  1312. this.table.temp.tcode = row.tcode
  1313. this.table.temp.tcolor = row.tcolor
  1314. this.table.temp.ccid = row.ccid
  1315. this.table.temp.ccname = this.table.temp.ccname
  1316. this.table.temp.fttype = this.table.temp.fttype
  1317. this.table.temp.fttypeid = row.fttypeid
  1318. this.table.temp.source = row.source
  1319. this.table.temp.remark = row.remark
  1320. this.table.temp.enable = row.enable
  1321. this.table.temp.pastureid = Cookies.get('pastureid')
  1322. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1323. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1324. return false
  1325. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1326. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1327. return false
  1328. } else if (this.table.temp.tname == '') {
  1329. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1330. return false
  1331. } else if (this.table.temp.ccid == '') {
  1332. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1333. return false
  1334. } else if (this.table.temp.fttypeid == '') {
  1335. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1336. return false
  1337. }
  1338. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1339. // if (pattern.test(this.table.temp.tname)) {
  1340. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1341. // return false
  1342. // }
  1343. if (pattern.test(this.table.temp.tcode)) {
  1344. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1345. return false
  1346. }
  1347. console.log(this.table.temp)
  1348. this.isokDisable = true
  1349. setTimeout(() => {
  1350. this.isokDisable = false
  1351. }, 1000)
  1352. this.requestParam2.name = 'checkNumber'
  1353. this.requestParam2.parammaps = {}
  1354. this.requestParam2.parammaps.number = this.table.temp.tcode
  1355. GetDataByName(this.requestParam2).then(response => {
  1356. console.log('table数据', response.data.list)
  1357. if (response.data.list[0].vmsg !== '输入非法字符') {
  1358. this.saveCreateData()
  1359. } else {
  1360. this.$notify({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1361. }
  1362. })
  1363. },
  1364. saveCreateData() {
  1365. this.requestParam.name = 'insertFT'
  1366. this.requestParam.parammaps = this.table.temp
  1367. PostDataByName(this.requestParam).then(response => {
  1368. console.log('新增保存发送参数', this.requestParam)
  1369. if (response.msg !== 'fail') {
  1370. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1371. this.getList()
  1372. } else {
  1373. const isRepeat = new RegExp('Duplicate entry :feedtemplet.tCode')
  1374. if (isRepeat.test(response.data)) {
  1375. this.$notify({ type: 'error', message: '配方编码不可重复,请重新录入', duration: 2000 })
  1376. } else {
  1377. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1378. }
  1379. }
  1380. })
  1381. },
  1382. createCancel(row) {
  1383. console.log('点击了新增取消')
  1384. for (let i = 0; i < this.table.list.length; i++) {
  1385. if (row.myId === this.table.list[i].myId) {
  1386. var listIndex = this.table.list.indexOf(this.table.list[i])
  1387. }
  1388. if (listIndex > -1) {
  1389. this.table.list.splice(listIndex, 1)
  1390. return
  1391. }
  1392. }
  1393. },
  1394. // 模板编辑
  1395. handleUpdate(row) {
  1396. for (let i = 0; i < this.table.list.length; i++) {
  1397. if (this.table.list[i].Edit == true) {
  1398. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1399. return false
  1400. }
  1401. }
  1402. // 编辑true,不可编辑false
  1403. row.Edit = true
  1404. row.NoEdit = false
  1405. // 新增false,编辑false,编辑保存true
  1406. row.isCreate = false
  1407. row.isUpdate = false
  1408. row.isUpdateSave = true
  1409. if (row.ccname !== undefined) {
  1410. row.ccid = String(row.ccid)
  1411. }
  1412. this.table.temp.ccname = row.ccname
  1413. row.fttypeid = String(row.fttypeid)
  1414. this.table.temp.fttype = row.fttype
  1415. },
  1416. updateData(row) {
  1417. console.log('点击了编辑保存', row)
  1418. this.table.temp.tname = row.tname
  1419. this.table.temp.tcode = row.tcode
  1420. this.table.temp.tcolor = row.tcolor
  1421. this.table.temp.ccid = row.ccid
  1422. this.table.temp.fttypeid = row.fttypeid
  1423. this.table.temp.source = row.source
  1424. this.table.temp.remark = row.remark
  1425. this.table.temp.enable = row.enable
  1426. this.table.temp.ccname = this.table.temp.ccname
  1427. this.table.temp.fttype = this.table.temp.fttype
  1428. this.table.temp.pastureid = row.pastureid
  1429. this.table.temp.id = row.id
  1430. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1431. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1432. return false
  1433. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1434. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1435. return false
  1436. } else if (this.table.temp.tname == '') {
  1437. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1438. return false
  1439. } else if (this.table.temp.ccid == '') {
  1440. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1441. return false
  1442. } else if (this.table.temp.fttypeid == '') {
  1443. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1444. return false
  1445. }
  1446. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1447. // if (pattern.test(this.table.temp.tname)) {
  1448. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1449. // return false
  1450. // }
  1451. if (pattern.test(this.table.temp.tcode)) {
  1452. this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1453. return false
  1454. }
  1455. console.log(this.table.temp)
  1456. this.isokDisable = true
  1457. setTimeout(() => {
  1458. this.isokDisable = false
  1459. }, 1000)
  1460. this.requestParam2.name = 'checkNumber'
  1461. this.requestParam2.parammaps = {}
  1462. this.requestParam2.parammaps.number = this.table.temp.tcode
  1463. GetDataByName(this.requestParam2).then(response => {
  1464. console.log('table数据', response.data.list)
  1465. if (response.data.list[0].vmsg !== '输入非法字符') {
  1466. this.saveUpdateData()
  1467. } else {
  1468. this.$notify({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1469. }
  1470. })
  1471. },
  1472. saveUpdateData() {
  1473. this.requestParam.name = 'updateFT'
  1474. this.requestParam.parammaps = this.table.temp
  1475. PostDataByName(this.requestParam).then(response => {
  1476. console.log('新增保存发送参数', this.requestParam)
  1477. if (response.msg !== 'fail') {
  1478. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1479. this.getList()
  1480. } else {
  1481. const isRepeat = new RegExp('Duplicate entry :feedtemplet.tCode')
  1482. if (isRepeat.test(response.data)) {
  1483. this.$notify({ type: 'error', message: '配方编码不可重复,请重新录入', duration: 2000 })
  1484. } else {
  1485. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1486. }
  1487. }
  1488. })
  1489. },
  1490. updateCancel(row) {
  1491. console.log('点击了编辑取消')
  1492. // 编辑false,不可编辑true
  1493. row.Edit = false
  1494. row.NoEdit = true
  1495. // 新增false,编辑true,编辑保存false
  1496. row.isCreate = false
  1497. row.isUpdate = true
  1498. row.isUpdateSave = false
  1499. this.getList()
  1500. },
  1501. // 删除
  1502. handleRowDelete(row) {
  1503. console.log('点击了行内删除')
  1504. MessageBox.confirm('是否确认删除此信息?', {
  1505. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1506. }).then(() => {
  1507. this.requestParam.common = { 'returnmap': '0' }
  1508. this.requestParam.data = []
  1509. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1510. pastureid: row.pastureid,
  1511. id: row.id
  1512. }}
  1513. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1514. pastureid: row.pastureid,
  1515. id: row.id
  1516. }}
  1517. ExecDataByConfig(this.requestParam).then(response => {
  1518. console.log('新增保存发送参数', this.requestParam)
  1519. if (response.msg === 'fail') {
  1520. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1521. } else {
  1522. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1523. this.getList()
  1524. this.isDetail = false
  1525. }
  1526. })
  1527. }).catch(() => {
  1528. this.$message({ type: 'info', message: '已取消删除' })
  1529. })
  1530. },
  1531. handleSelectionChange(val) {
  1532. console.log('勾选数据', val)
  1533. this.selectList = val
  1534. },
  1535. handleDelete() {
  1536. console.log('点击了删除')
  1537. if (this.selectList.length == 0) {
  1538. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1539. } else {
  1540. MessageBox.confirm('是否确认删除此信息?', {
  1541. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1542. }).then(() => {
  1543. console.log(this.selectList)
  1544. this.requestParam.common = { 'returnmap': '0' }
  1545. this.requestParam.data = []
  1546. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1547. this.requestParam.data[0].children = []
  1548. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1549. id: '@insertSpotList.id',
  1550. pastureid: '@insertSpotList.pastureid'
  1551. }}
  1552. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1553. id: '@insertSpotList.id',
  1554. pastureid: '@insertSpotList.pastureid'
  1555. }}
  1556. ExecDataByConfig(this.requestParam).then(response => {
  1557. console.log('删除保存发送参数', this.requestParam)
  1558. if (response.msg === 'fail') {
  1559. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1560. } else {
  1561. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1562. this.getList()
  1563. }
  1564. })
  1565. })
  1566. }
  1567. },
  1568. // 复制
  1569. handleCopy() {
  1570. if (this.selectList.length == 0) {
  1571. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1572. } else {
  1573. MessageBox.confirm('是否确认复制此信息?', {
  1574. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1575. }).then(() => {
  1576. console.log(this.selectList)
  1577. this.requestParam.common = { 'returnmap': '0' }
  1578. this.requestParam.data = []
  1579. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1580. this.requestParam.data[0].children = []
  1581. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1582. ftid: '@insertSpotList.id',
  1583. pastureid: '@insertSpotList.pastureid'
  1584. }}
  1585. ExecDataByConfig(this.requestParam).then(response => {
  1586. console.log('复制保存发送参数', this.requestParam)
  1587. if (response.msg === 'fail') {
  1588. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1589. } else {
  1590. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1591. this.getList()
  1592. }
  1593. })
  1594. })
  1595. }
  1596. },
  1597. // 配方记录
  1598. handleRecipeRecord() {
  1599. console.log('点击了配方记录')
  1600. this.template.dialogStatus = 'RecipeRecord'
  1601. this.dialogFull = false
  1602. this.template.dialogFormVisible = true
  1603. this.template.table.getdataListParm.parammaps.ccname = ''
  1604. this.template.table.getdataListParm.parammaps.fttype = ''
  1605. this.template.table.getdataListParm.parammaps.enable = ''
  1606. this.template.table.getdataListParm.parammaps.tname = ''
  1607. this.template.table.getdataListParm.parammaps.remark = ''
  1608. this.template.table.getdataListParm.parammaps.source = ''
  1609. this.template.table.getdataListParm.offset = 1
  1610. this.getDateList()
  1611. this.isDetailDialog = false
  1612. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  1613. },
  1614. // 历史时间
  1615. getDateList() {
  1616. GetDataByName(this.template.getdataDateParm).then(response => {
  1617. console.log('table数据', response.data.list)
  1618. if (response.data.list !== null) {
  1619. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1620. this.getTemplateDialogList()
  1621. } else {
  1622. this.template.table.getdataListParm.parammaps.date = ''
  1623. }
  1624. })
  1625. },
  1626. // 配方记录-模板
  1627. getTemplateDialogList() {
  1628. this.template.table.listLoading = true
  1629. GetDataByName(this.template.table.getdataListParm).then(response => {
  1630. console.log('table数据', response.data.list)
  1631. if (response.data.list !== null) {
  1632. this.template.table.list = response.data.list
  1633. this.template.table.pageNum = response.data.pageNum
  1634. this.template.table.pageSize = response.data.pageSize
  1635. this.template.table.total = response.data.total
  1636. } else {
  1637. this.template.table.list = []
  1638. this.template.table2.list = []
  1639. }
  1640. setTimeout(() => {
  1641. this.template.table.listLoading = false
  1642. }, 100)
  1643. })
  1644. },
  1645. handleDialogSearch() {
  1646. this.template.table.getdataListParm.offset = 1
  1647. this.getTemplateDialogList()
  1648. this.arrowDown = true
  1649. this.arrowUp = false
  1650. },
  1651. handleDialogRefresh() {
  1652. this.template.table.getdataListParm.parammaps.ccname = ''
  1653. this.template.table.getdataListParm.parammaps.fttype = ''
  1654. this.template.table.getdataListParm.parammaps.enable = ''
  1655. this.template.table.getdataListParm.parammaps.tname = ''
  1656. this.template.table.getdataListParm.parammaps.remark = ''
  1657. this.template.table.getdataListParm.parammaps.source = ''
  1658. this.template.table.getdataListParm.offset = 1
  1659. this.getTemplateDialogList()
  1660. },
  1661. // 配方记录-模板行点击
  1662. tableRowClickDialog(row, column, event) {
  1663. console.log('配方记录-模板行点击')
  1664. this.isDetailDialog = true
  1665. this.template.table2.getdataListParm.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1666. this.template.table2.getdataListParm.parammaps.version = row.version
  1667. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1668. this.template.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1669. this.myheight2 = document.documentElement.clientHeight - 85 - 265 - 185
  1670. this.getDialogList()
  1671. this.getDownList()
  1672. // aiaiaiai
  1673. },
  1674. getDialogList() {
  1675. this.template.table2.listLoading = true
  1676. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1677. console.log('table数据', response.data.list)
  1678. if (response.data.list !== null) {
  1679. this.template.table2.list = response.data.list
  1680. this.template.table2.pageNum = response.data.pageNum
  1681. this.template.table2.pageSize = response.data.pageSize
  1682. this.template.table2.total = response.data.total
  1683. } else {
  1684. this.template.table2.list = []
  1685. }
  1686. this.$nextTick(function() {
  1687. document.querySelector('#detailDialog2').scrollIntoView()
  1688. // window.scrollTo({
  1689. // 'top': this.$refs.detailDialog2.clientHeight
  1690. // })
  1691. })
  1692. setTimeout(() => {
  1693. this.template.table2.listLoading = false
  1694. }, 100)
  1695. })
  1696. },
  1697. handleDialogSearch2() {
  1698. console.log('点击了查询')
  1699. this.arrowDown2 = true
  1700. this.arrowUp2 = false
  1701. this.template.table2.getdataListParm.offset = 1
  1702. this.getDialogList2()
  1703. },
  1704. handleDialogRefresh2() {
  1705. console.log('点击了重置')
  1706. this.template.table2.getdataListParm.parammaps.fname = ''
  1707. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1708. this.template.table2.getdataListParm.parammaps.fweight = ''
  1709. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1710. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1711. this.template.table2.getdataListParm.parammaps.sort = ''
  1712. this.template.table2.getdataListParm.offset = 1
  1713. this.getDialogList2()
  1714. },
  1715. getDialogList2() {
  1716. this.template.table2.listLoading = true
  1717. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1718. console.log('table数据', response.data.list)
  1719. if (response.data.list !== null) {
  1720. this.template.table2.list = response.data.list
  1721. this.template.table2.pageNum = response.data.pageNum
  1722. this.template.table2.pageSize = response.data.pageSize
  1723. this.template.table2.total = response.data.total
  1724. } else {
  1725. this.template.table2.list = []
  1726. }
  1727. this.$nextTick(function() {
  1728. window.scrollTo({
  1729. 'top': this.$refs.templateDialog.clientHeight
  1730. })
  1731. })
  1732. setTimeout(() => {
  1733. this.template.table2.listLoading = false
  1734. }, 100)
  1735. })
  1736. },
  1737. // 导出
  1738. handleExport(item) {
  1739. if (item == 1) {
  1740. console.log('点击了导出模板')
  1741. const requestParam = this.requestParam
  1742. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/配方计划/配方模板导入模板.xlsx' // 请求下载文件的地址
  1743. console.log(url)
  1744. axios({
  1745. method: 'GET',
  1746. url: url,
  1747. data: requestParam,
  1748. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1749. responseType: 'blob'
  1750. }).then(res => {
  1751. if (!res) return
  1752. this.percentage = 99
  1753. setTimeout(() => {
  1754. this.isPercentage = false
  1755. }, 2000)
  1756. const blob = new Blob([res.data], {
  1757. type: 'application/octet-stream;charset=utf-8'
  1758. })
  1759. const url = window.URL.createObjectURL(blob)
  1760. const aLink = document.createElement('a')
  1761. aLink.style.display = 'none'
  1762. aLink.href = url
  1763. const docname = '配方模板导入模板.xlsx'
  1764. aLink.setAttribute('download', docname) // 下载的文件
  1765. document.body.appendChild(aLink)
  1766. aLink.click()
  1767. document.body.removeChild(aLink)
  1768. window.URL.revokeObjectURL(url)
  1769. })
  1770. } else {
  1771. console.log('点击了导出数据')
  1772. this.download.getdataListParm.name = 'downloadFTList'
  1773. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1774. GetDataByName(this.download.getdataListParm).then(response => {
  1775. if (response.data.list !== null) {
  1776. for (let i = 0; i < response.data.list.length; i++) {
  1777. if (response.data.list[i].islockcount == 0) {
  1778. this.$set(response.data.list[i], 'islockcount', '否')
  1779. } else {
  1780. this.$set(response.data.list[i], 'islockcount', '是')
  1781. }
  1782. if (response.data.list[i].enable == 0) {
  1783. this.$set(response.data.list[i], 'enable', '否')
  1784. } else {
  1785. this.$set(response.data.list[i], 'enable', '是')
  1786. }
  1787. }
  1788. this.download.list = response.data.list
  1789. } else {
  1790. this.download.list = []
  1791. }
  1792. var excelDatas = [
  1793. {
  1794. tHeader: ['配方名称', '配方编码', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1795. filterVal: ['tname', 'tcode', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1796. tableDatas: this.download.list,
  1797. sheetName: 'Sheet1'
  1798. }
  1799. ]
  1800. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1801. })
  1802. }
  1803. },
  1804. beforeImport(file) {
  1805. const isLt2M = file.size / 1024 / 1024 < 2
  1806. if (!isLt2M) {
  1807. this.$message.error('上传文件大小不能超过 2MB!')
  1808. }
  1809. return isLt2M
  1810. },
  1811. handleImportSuccess(res, file) {
  1812. this.getList()
  1813. if (res.msg === 'ok') {
  1814. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1815. if (res.data.err_count > 0) {
  1816. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1817. import('@/vendor/Export2Excel').then(excel => {
  1818. const list1 = res.data.result
  1819. const tHeader = [
  1820. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1821. ]
  1822. const filterVal = [
  1823. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1824. ]
  1825. const data1 = this.formatJson(filterVal, list1)
  1826. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1827. })
  1828. }
  1829. } else {
  1830. const isRepeat = new RegExp('Duplicate entry :feedtemplet_tname')
  1831. if (isRepeat.test(res.data)) {
  1832. this.$notify({ type: 'error', message: '配方名称不可重复,请重新录入', duration: 2000 })
  1833. return false
  1834. }
  1835. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1836. }
  1837. },
  1838. formatJson(filterVal, jsonData) {
  1839. return jsonData.map(v =>
  1840. filterVal.map(j => {
  1841. if (j === 'timestamp') {
  1842. return parseTime(v[j])
  1843. } else {
  1844. return v[j]
  1845. }
  1846. })
  1847. )
  1848. },
  1849. changeDate() {
  1850. this.getTemplateDialogList()
  1851. },
  1852. // 应用
  1853. handleApplication() {
  1854. console.log('点击了应用')
  1855. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1856. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1857. }).then(() => {
  1858. this.requestParam.name = 'applyFTdate'
  1859. this.requestParam.parammaps = {}
  1860. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1861. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1862. PostDataByName(this.requestParam).then(response => {
  1863. if (response.msg === 'fail') {
  1864. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1865. } else {
  1866. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1867. this.getTemplateDialogList()
  1868. this.getList()
  1869. }
  1870. })
  1871. }).catch(() => {
  1872. this.$message({ type: 'info', message: '已取消应用' })
  1873. })
  1874. },
  1875. // 模板行点击
  1876. tableRowClick(row, column, event) {
  1877. for (let i = 0; i < this.table.list.length; i++) {
  1878. if (this.table.list[i].Edit == true) {
  1879. return false
  1880. }
  1881. }
  1882. if (this.isOrder == false) {
  1883. this.$message({ type: 'error', message: '请保存或取消当前更改顺序操作', duration: 2000 })
  1884. } else {
  1885. if (column.label !== '操作') {
  1886. this.isDetail = true // 点击行显示详情
  1887. this.table2.getdataListParm.parammaps.ftid = row.id
  1888. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1889. this.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1890. if (row.fttype == '预混配方') {
  1891. this.requestParams[2].parammaps.type = '1'
  1892. } else {
  1893. this.requestParams[2].parammaps.type = ''
  1894. }
  1895. this.myheight = document.documentElement.clientHeight - 85 - 265 - 185
  1896. this.getList2()
  1897. this.getDownList()
  1898. }
  1899. }
  1900. },
  1901. handleCloseTable2() {
  1902. this.isDetail = false
  1903. this.myheight = ''
  1904. this.isEnlarge = true
  1905. },
  1906. handleDialogCloseTable2() {
  1907. this.isDetailDialog = false
  1908. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  1909. },
  1910. // -------------------详情-----------------------------
  1911. // 获取是否显示是否锁定牛头数
  1912. getIsLockCount() {
  1913. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1914. console.log(response.data.list)
  1915. if (response.data.list[0].inforvalue == 0) {
  1916. this.lockCount.isLockCount = false
  1917. } else {
  1918. this.lockCount.isLockCount = true
  1919. }
  1920. })
  1921. },
  1922. // 详情
  1923. getList2() {
  1924. this.table2.listLoading = true
  1925. GetDataByName(this.table2.getdataListParm).then(response => {
  1926. console.log('table数据', response.data.list)
  1927. if (response.data.list !== null) {
  1928. for (let i = 0; i < response.data.list.length; i++) {
  1929. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1930. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1931. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1932. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1933. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1934. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1935. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1936. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1937. }
  1938. this.table2.getDryweightParm.parammaps = this.table2.getdataListParm.parammaps
  1939. this.getDryWeight()
  1940. // for (let i = 0; i < response.data.list.length; i++) {
  1941. // console.log(response.data.list[i].fweight, '===12333')
  1942. // }
  1943. this.table2.list = response.data.list
  1944. this.table2.pageNum = response.data.pageNum
  1945. this.table2.pageSize = response.data.pageSize
  1946. this.table2.total = response.data.total
  1947. } else {
  1948. this.table2.list = []
  1949. }
  1950. setTimeout(() => {
  1951. this.table2.listLoading = false
  1952. }, 100)
  1953. })
  1954. },
  1955. // 行拖拽
  1956. rowDrop() {
  1957. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1958. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1959. // this.sorTable()
  1960. const that = this
  1961. // Sortable.create(tbody, {
  1962. var sortable = Sortable.create(tbody, {
  1963. disabled: that.dropState,
  1964. onChoose({ newIndex, oldIndex }) {
  1965. console.log(that.isOrder, 'that.isOrder == false')
  1966. console.log(that.dropState, 'that.dropState')
  1967. if (that.dropState == true || that.isOrder == true) {
  1968. sortable.destroy()
  1969. }
  1970. },
  1971. onEnd({ newIndex, oldIndex }) {
  1972. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1973. that.table2.list.splice(newIndex, 0, currRow)
  1974. console.log('索引', newIndex)
  1975. console.log('拖动数据', currRow)
  1976. console.log('上', that.table2.list[newIndex - 1])
  1977. console.log('下', that.table2.list[newIndex + 1])
  1978. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1979. for (let i = 0; i < that.table2.list.length; i++) {
  1980. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1981. }
  1982. currRow.sort = 0
  1983. currRow.feedgroup = currRow.fname
  1984. console.log('拖动至最上方无值')
  1985. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1986. currRow.sort = that.table2.list[newIndex - 1].sort
  1987. console.log('拖动值顺序等于上值顺序')
  1988. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1989. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1990. currRow.feedgroup = currRow.fname
  1991. console.log('拖动至最下方无值')
  1992. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1993. currRow.sort == that.table2.list[newIndex + 1].sort
  1994. console.log('拖动值顺序等于下值顺序')
  1995. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1996. currRow.sort = that.table2.list[newIndex - 1].sort
  1997. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1998. console.log('拖动至上下顺序一致')
  1999. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  2000. console.log('上下')
  2001. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  2002. console.log(newIndex)
  2003. for (let i = newIndex; i < that.table2.list.length; i++) {
  2004. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  2005. }
  2006. }
  2007. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  2008. currRow.feedgroup = currRow.fname
  2009. console.log(that.table2.list[newIndex + 1].sort)
  2010. }
  2011. }
  2012. })
  2013. console.log(sortable.option('disabled'))
  2014. },
  2015. handleChangeOrder() {
  2016. this.isOrder = false
  2017. this.rowDrop()
  2018. },
  2019. saveChangeOrder() {
  2020. // 保存顺序
  2021. console.log(this.table2.list)
  2022. this.requestParam = {}
  2023. this.requestParam.common = { 'returnmap': '0' }
  2024. this.requestParam.data = []
  2025. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table2.list }}
  2026. this.requestParam.data[0].children = []
  2027. this.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  2028. id: '@insertSpotList.id',
  2029. pastureid: '@insertSpotList.pastureid',
  2030. sort: '@insertSpotList.sort',
  2031. feedgroup: '@insertSpotList.feedgroup'
  2032. }}
  2033. ExecDataByConfig(this.requestParam).then(response => {
  2034. console.log('顺序切换保存发送参数', this.requestParam)
  2035. if (response.msg === 'fail') {
  2036. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  2037. } else {
  2038. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  2039. this.getList2()
  2040. this.getList3()
  2041. this.isOrder = true
  2042. }
  2043. })
  2044. },
  2045. cancelChangeOrder() {
  2046. // 取消顺序
  2047. this.getList2()
  2048. this.isOrder = true
  2049. },
  2050. handleSearch2() {
  2051. console.log('点击了查询')
  2052. this.arrowDown2 = true
  2053. this.arrowUp2 = false
  2054. this.table2.getdataListParm.offset = 1
  2055. // fname, feedgroup, fweight, autosecondname, islockcount, sort
  2056. // this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.fname + ' ' + this.table2.getdataListParm.parammaps.feedgroup + ' ' + this.table2.getdataListParm.parammaps.fweight + ' ' + this.table2.getdataListParm.parammaps.autosecondname + ' ' + this.table2.getdataListParm.parammaps.islockcount + ' ' + this.table2.getdataListParm.parammaps.sort
  2057. this.table2.getdataListParm.parammaps.all = ''
  2058. var obj = {}
  2059. obj.fname = this.table2.getdataListParm.parammaps.fname
  2060. obj.feedgroup = this.table2.getdataListParm.parammaps.feedgroup
  2061. obj.fweight = this.table2.getdataListParm.parammaps.fweight
  2062. obj.autosecondname = this.table2.getdataListParm.parammaps.autosecondname
  2063. if (this.table2.getdataListParm.parammaps.islockcount !== '') {
  2064. if (this.table2.getdataListParm.parammaps.islockcount == 0) {
  2065. this.table2.getdataListParm.parammaps.islockcount = '否'
  2066. } else {
  2067. this.table2.getdataListParm.parammaps.islockcount = '是'
  2068. }
  2069. }
  2070. obj.islockcount = this.table2.getdataListParm.parammaps.islockcount
  2071. obj.sort = this.table2.getdataListParm.parammaps.sort
  2072. Object.getOwnPropertyNames(obj).forEach((key) => {
  2073. console.log(key, obj[key])
  2074. if (obj[key] !== '') {
  2075. this.table2.getdataListParm.parammaps.all += obj[key] + '/'
  2076. }
  2077. })
  2078. if (this.table2.getdataListParm.parammaps.all.charAt(this.table2.getdataListParm.parammaps.all.length - 1) == '/') {
  2079. this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.all.slice(0, this.table2.getdataListParm.parammaps.all.length - 1)
  2080. }
  2081. this.getList2()
  2082. },
  2083. handleRefresh2() {
  2084. console.log('点击了重置')
  2085. this.table2.getdataListParm.parammaps.fname = ''
  2086. this.table2.getdataListParm.parammaps.feedgroup = ''
  2087. this.table2.getdataListParm.parammaps.fweight = ''
  2088. this.table2.getdataListParm.parammaps.autosecondname = ''
  2089. this.table2.getdataListParm.parammaps.islockcount = '0'
  2090. this.table2.getdataListParm.parammaps.sort = ''
  2091. this.table2.getdataListParm.parammaps.all = ''
  2092. this.table2.getdataListParm.offset = 1
  2093. this.getList2()
  2094. },
  2095. // 详情新增
  2096. handleCreate2() {
  2097. console.log('点击了详情新增', this.table2.list)
  2098. // 编辑true/不可编辑false
  2099. // 新增操true,编辑false,编辑保存false
  2100. console.log(11)
  2101. for (let i = 0; i < this.table2.list.length; i++) {
  2102. if (this.table2.list[i].Edit === true) {
  2103. console.log(123)
  2104. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2105. return false
  2106. }
  2107. }
  2108. console.log(this.table2.list)
  2109. if (this.table2.list.length == 0) {
  2110. var mysort = 0
  2111. } else {
  2112. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2113. }
  2114. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  2115. console.log(this.table2.list)
  2116. },
  2117. changeFname(item, row) {
  2118. console.log(item, row)
  2119. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  2120. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  2121. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  2122. this.table2.temp.preftid = '0'
  2123. } else {
  2124. this.table2.temp.preftid = item
  2125. }
  2126. if (row.sort == '') {
  2127. row.feedgroup = this.table2.temp.fname
  2128. } else {
  2129. if (row.isCreate == true) { // 新增状态下
  2130. for (let i = 1; i < this.table2.list.length; i++) {
  2131. if (this.table2.list[i].sort == row.sort) {
  2132. console.log(this.table2.list[i])
  2133. row.feedgroup = this.table2.list[i].feedgroup
  2134. break
  2135. } else {
  2136. row.feedgroup = this.table2.temp.fname
  2137. }
  2138. }
  2139. } else if (row.isUpdateSave == true) { // 编辑状态下
  2140. var Arr = []
  2141. for (let i = 0; i < this.table2.list.length; i++) {
  2142. Arr.push(this.table2.list[i].sort)
  2143. }
  2144. var Count = 0
  2145. for (let i = 0; i < Arr.length; i++) {
  2146. if (Arr[i] == row.sort) {
  2147. Count++
  2148. }
  2149. }
  2150. for (let i = 0; i < this.table2.list.length; i++) {
  2151. if (Count > 1) {
  2152. row.feedgroup = this.table2.list[i].feedgroup
  2153. console.log(this.table2.list[i].feedgroup)
  2154. break
  2155. } else if (Count == 1) {
  2156. row.feedgroup = this.table2.temp.fname
  2157. console.log(222, this.table2.temp.fname)
  2158. }
  2159. }
  2160. }
  2161. }
  2162. },
  2163. bort(row) {
  2164. if (row.isCreate == true) {
  2165. if (row.sort !== '') {
  2166. for (let i = 1; i < this.table2.list.length; i++) {
  2167. if (this.table2.list[i].sort == parseInt(row.sort)) {
  2168. row.feedgroup = this.table2.list[i].feedgroup
  2169. return false
  2170. } else {
  2171. row.feedgroup = row.fname
  2172. }
  2173. }
  2174. } else {
  2175. row.feedgroup = row.fname
  2176. }
  2177. } else if (row.isUpdateSave == true) {
  2178. if (row.sort !== '') {
  2179. for (let i = 0; i < this.table2.list.length; i++) {
  2180. if (this.table2.list[i].sort == row.sort) {
  2181. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  2182. if (this.table2.list[i].id !== row.id) {
  2183. row.isGroupDisabled = true
  2184. row.feedgroup = this.table2.list[i].feedgroup
  2185. break
  2186. }
  2187. } else {
  2188. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  2189. row.isGroupDisabled = true
  2190. row.feedgroup = row.fname
  2191. }
  2192. }
  2193. } else {
  2194. row.feedgroup = row.fname
  2195. }
  2196. }
  2197. },
  2198. createData2(row) {
  2199. console.log('点击了详情新增保存1', row)
  2200. this.table2.temp.pastureid = Cookies.get('pastureid')
  2201. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2202. this.table2.temp.fid = row.fid
  2203. this.table2.temp.fname = this.table2.temp.fname
  2204. this.table2.temp.fweight = row.fweight
  2205. this.table2.temp.islockcount = row.islockcount
  2206. this.table2.temp.sort = row.sort
  2207. this.table2.temp.feedgroup = row.feedgroup
  2208. this.table2.temp.preftid = this.table2.temp.preftid
  2209. this.table2.temp.autosecond = row.autosecond
  2210. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2211. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2212. return false
  2213. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2214. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2215. return false
  2216. } else if (this.table2.temp.fid == '') {
  2217. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2218. return false
  2219. } else if (this.table2.temp.fweight == '') {
  2220. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2221. return false
  2222. } else if (this.table2.temp.autosecond == '') {
  2223. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2224. return false
  2225. }
  2226. if (this.table2.temp.sort !== '') {
  2227. this.table2.temp.sort = this.table2.temp.sort
  2228. } else {
  2229. console.log(this.table2.list.length)
  2230. if (this.table2.list.length == 1) {
  2231. this.table2.temp.sort = 0
  2232. } else {
  2233. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2234. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2235. }
  2236. }
  2237. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2238. if (parseInt(this.table2.temp.preftid) > 0) {
  2239. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2240. return false
  2241. }
  2242. }
  2243. // 校验顺序是否>=0
  2244. var ruleSort = /^\d+$/
  2245. if (!ruleSort.test(this.table2.temp.sort)) {
  2246. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2247. return false
  2248. }
  2249. // 检验重量>0
  2250. this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 3) // 根据默认参数设置小数位数
  2251. row.fweight = formatNum(row.fweight, 3)
  2252. // var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2253. if (this.table2.temp.fweight == 0) {
  2254. this.$message({ type: 'error', message: '重量请输入正数,最多保留三位小数', duration: 2000 })
  2255. return false
  2256. }
  2257. this.isokDisable = true
  2258. setTimeout(() => {
  2259. this.isokDisable = false
  2260. }, 1000)
  2261. this.requestParam.common = { 'returnmap': '0' }
  2262. this.requestParam.data = []
  2263. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2264. pastureid: this.table2.temp.pastureid,
  2265. ftid: this.table2.getdataListParm.parammaps.ftid,
  2266. fid: row.fid,
  2267. fname: this.table2.temp.fname,
  2268. fweight: String(row.fweight),
  2269. islockcount: row.islockcount,
  2270. sort: row.sort,
  2271. feedgroup: row.feedgroup,
  2272. preftid: this.table2.temp.preftid,
  2273. autosecond: row.autosecond
  2274. }}
  2275. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2276. pastureid: this.table2.temp.pastureid,
  2277. ftid: this.table2.getdataListParm.parammaps.ftid,
  2278. type: this.table2.getdataListParm.parammaps.fttypeid,
  2279. status: 0
  2280. }}
  2281. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2282. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2283. id: this.table2.getdataListParm.parammaps.ftid
  2284. }}
  2285. this.requestParam.data[3] = { 'name': 'insertFitHistory', 'type': 'e', 'parammaps': {
  2286. weight: row.fweight,
  2287. preftid: this.table2.temp.preftid,
  2288. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2289. ftid: this.table2.getdataListParm.parammaps.ftid,
  2290. dateTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
  2291. slid: 0,
  2292. fid: row.fid
  2293. }}
  2294. const url = 'authdata/ftdetail/edit'
  2295. const data = this.requestParam
  2296. postJson(url, data).then(response => {
  2297. if (response.msg !== 'fail') {
  2298. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2299. this.getList2()
  2300. this.getList3()
  2301. } else {
  2302. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2303. }
  2304. })
  2305. // ExecDataByConfig(this.requestParam).then(response => {
  2306. // console.log('新增保存发送参数', this.requestParam)
  2307. // if (response.msg !== 'fail') {
  2308. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2309. // this.getList2()
  2310. // this.getList3()
  2311. // } else {
  2312. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2313. // }
  2314. // })
  2315. },
  2316. createCancel2(row) {
  2317. console.log('点击了详情新增取消')
  2318. for (let i = 0; i < this.table2.list.length; i++) {
  2319. if (row.myId === this.table2.list[i].myId) {
  2320. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  2321. }
  2322. if (listIndex > -1) {
  2323. this.table2.list.splice(listIndex, 1)
  2324. return
  2325. }
  2326. }
  2327. this.getDialogList()
  2328. },
  2329. // 详情编辑
  2330. handleUpdate2(row) {
  2331. console.log('详情编辑', row)
  2332. this.dropState = true
  2333. row.isGroupDisabled = false
  2334. row.islockcount = String(row.islockcount)
  2335. row.fid = String(row.fid)
  2336. row.autosecond = String(row.autosecond)
  2337. this.table2.temp.fname = row.fname
  2338. this.table2.temp.preftid = row.preftid
  2339. const rowArr = []
  2340. for (let i = 0; i < this.table2.list.length; i++) {
  2341. if (this.table2.list[i].Edit == true) {
  2342. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2343. return false
  2344. }
  2345. rowArr.push(this.table2.list[i].sort)
  2346. }
  2347. var count = 0
  2348. for (let i = 0; i < rowArr.length; i++) {
  2349. if (rowArr[i] == row.sort) {
  2350. count++
  2351. }
  2352. }
  2353. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  2354. if (count == 1) {
  2355. // 饲料组编辑false,不可编辑true
  2356. row.groupEdit = false
  2357. row.groupNoEdit = true
  2358. // 编辑true,不可编辑false
  2359. row.Edit = true
  2360. row.NoEdit = false
  2361. // 新增false,编辑false,编辑保存true
  2362. row.isCreate = false
  2363. row.isUpdate = false
  2364. row.isUpdateSave = true
  2365. } else if (count > 1) {
  2366. // 饲料组编辑true,不可编辑false
  2367. row.groupEdit = true
  2368. row.groupNoEdit = false
  2369. console.log(222)
  2370. // 编辑true,不可编辑false
  2371. row.Edit = true
  2372. row.NoEdit = false
  2373. // 新增false,编辑false,编辑保存true
  2374. row.isCreate = false
  2375. row.isUpdate = false
  2376. row.isUpdateSave = true
  2377. return false
  2378. }
  2379. this.table2.updateList = Object.assign({}, row)
  2380. },
  2381. updateData2(row) {
  2382. console.log('点击了详情编辑保存', row)
  2383. this.isokDisable = true
  2384. setTimeout(() => {
  2385. this.isokDisable = false
  2386. }, 1000)
  2387. this.table2.temp.pastureid = row.pastureid
  2388. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2389. this.table2.temp.fid = row.fid
  2390. this.table2.temp.fname = this.table2.temp.fname
  2391. this.table2.temp.fweight = row.fweight
  2392. this.table2.temp.islockcount = row.islockcount
  2393. this.table2.temp.sort = row.sort
  2394. this.table2.temp.feedgroup = row.feedgroup
  2395. this.table2.temp.preftid = this.table2.temp.preftid
  2396. this.table2.temp.autosecond = row.autosecond
  2397. this.table2.temp.id = row.id
  2398. console.log('this.table2.updateList', this.table2.updateList)
  2399. console.log('temp', this.table2.temp)
  2400. // var status = ''
  2401. // if (parseFloat(this.table2.temp.fweight) > parseFloat(this.table2.updateList.fweight)) {
  2402. // status = 0
  2403. // } else {
  2404. // status = 1
  2405. // }
  2406. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2407. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2408. return false
  2409. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2410. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2411. return false
  2412. } else if (this.table2.temp.fid == '') {
  2413. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2414. return false
  2415. } else if (this.table2.temp.fweight == '') {
  2416. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2417. return false
  2418. } else if (this.table2.temp.autosecond == '') {
  2419. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2420. return false
  2421. }
  2422. if (this.table2.temp.sort !== '') {
  2423. this.table2.temp.sort = this.table2.temp.sort
  2424. } else {
  2425. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2426. }
  2427. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2428. if (parseInt(this.table2.temp.preftid) > 0) {
  2429. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2430. return false
  2431. }
  2432. }
  2433. // 校验顺序是否>=0
  2434. var ruleSort = /^\d+$/
  2435. if (!ruleSort.test(this.table2.temp.sort)) {
  2436. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2437. return false
  2438. }
  2439. this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 3) // 根据默认参数设置小数位数
  2440. row.fweight = formatNum(row.fweight, 3)
  2441. // 检验重量>0
  2442. // var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2443. if (this.table2.temp.fweight == 0) {
  2444. this.$message({ type: 'error', message: '重量请输入正数,最多保留三位小数', duration: 2000 })
  2445. return false
  2446. }
  2447. this.requestParam.common = { 'returnmap': '0' }
  2448. this.requestParam.data = []
  2449. this.requestParam.data[0] = { 'name': 'insertFitHistory', 'type': 'e', 'parammaps': {
  2450. pastureid: row.pastureid,
  2451. ftid: this.table2.getdataListParm.parammaps.ftid,
  2452. weight: String(row.fweight),
  2453. preftid: this.table2.temp.preftid,
  2454. dateTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
  2455. slid: this.table2.temp.id,
  2456. fid: row.fid
  2457. }}
  2458. this.requestParam.data[1] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  2459. pastureid: row.pastureid,
  2460. ftid: this.table2.getdataListParm.parammaps.ftid,
  2461. fid: row.fid,
  2462. fname: this.table2.temp.fname,
  2463. fweight: String(row.fweight),
  2464. islockcount: row.islockcount,
  2465. sort: row.sort,
  2466. feedgroup: row.feedgroup,
  2467. preftid: this.table2.temp.preftid,
  2468. autosecond: row.autosecond,
  2469. id: row.id
  2470. }}
  2471. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2472. pastureid: row.pastureid,
  2473. ftid: this.table2.getdataListParm.parammaps.ftid,
  2474. type: this.table2.getdataListParm.parammaps.fttypeid,
  2475. // status: status
  2476. }}
  2477. this.requestParam.data[3] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  2478. pastureid: row.pastureid,
  2479. ftid: this.table2.getdataListParm.parammaps.ftid,
  2480. sort: row.sort,
  2481. feedgroup: row.feedgroup
  2482. }}
  2483. this.requestParam.data[4] = { 'name': 'updateFTdetailGroup', 'type': 'e', 'parammaps': {
  2484. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2485. ftid: this.table2.getdataListParm.parammaps.ftid
  2486. }}
  2487. const url = 'authdata/ftdetail/edit'
  2488. const data = this.requestParam
  2489. postJson(url, data).then(response => {
  2490. if (response.msg !== 'fail') {
  2491. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2492. this.getList2()
  2493. this.getList3()
  2494. this.dropState = false
  2495. } else {
  2496. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2497. }
  2498. })
  2499. // ExecDataByConfig(this.requestParam).then(response => {
  2500. // console.log('新增保存发送参数', this.requestParam)
  2501. // if (response.msg !== 'fail') {
  2502. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2503. // this.getList2()
  2504. // this.getList3()
  2505. // this.dropState = false
  2506. // } else {
  2507. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2508. // }
  2509. // })
  2510. },
  2511. updateCancel2(row) {
  2512. console.log('点击了详情编辑取消')
  2513. // 饲料组编辑false,不可编辑true
  2514. row.groupEdit = false
  2515. row.groupNoEdit = true
  2516. // 编辑false,不可编辑true
  2517. row.Edit = false
  2518. row.NoEdit = true
  2519. // 新增false,编辑true,编辑保存false
  2520. row.isCreate = false
  2521. row.isUpdate = true
  2522. row.isUpdateSave = false
  2523. this.getList2()
  2524. this.dropState = false
  2525. },
  2526. // 详情删除
  2527. handleRowDelete2(row) {
  2528. console.log('点击了行内删除')
  2529. MessageBox.confirm('是否确认删除此信息?', {
  2530. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2531. }).then(() => {
  2532. console.log(this.table2.list.length)
  2533. if (this.table2.list.length > 1) {
  2534. this.requestParam.common = { 'returnmap': '0' }
  2535. this.requestParam.data = []
  2536. this.requestParam.data[0] = { 'name': 'insertFitHistory', 'type': 'e', 'parammaps': {
  2537. pastureid: row.pastureid,
  2538. ftid: this.table2.getdataListParm.parammaps.ftid,
  2539. weight: 0,
  2540. preftid: row.preftid,
  2541. dateTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
  2542. slid: row.id,
  2543. fid: row.fid
  2544. }}
  2545. this.requestParam.data[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2546. pastureid: row.pastureid,
  2547. id: row.id
  2548. }}
  2549. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2550. pastureid: row.pastureid,
  2551. ftid: this.table2.getdataListParm.parammaps.ftid,
  2552. type: this.table2.getdataListParm.parammaps.fttypeid,
  2553. status: 1
  2554. }}
  2555. this.requestParam.data[3] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2556. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2557. id: this.table2.getdataListParm.parammaps.ftid
  2558. }}
  2559. } else {
  2560. this.requestParam.common = { 'returnmap': '0' }
  2561. this.requestParam.data = []
  2562. this.requestParam.data[0] = { 'name': 'insertFitHistory', 'type': 'e', 'parammaps': {
  2563. pastureid: row.pastureid,
  2564. ftid: this.table2.getdataListParm.parammaps.ftid,
  2565. weight: 0,
  2566. preftid: row.preftid,
  2567. dateTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
  2568. slid: row.id,
  2569. fid: row.fid
  2570. }}
  2571. this.requestParam.data[1] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2572. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2573. id: this.table2.getdataListParm.parammaps.ftid
  2574. }}
  2575. this.requestParam.data[2] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2576. pastureid: row.pastureid,
  2577. id: row.id
  2578. }}
  2579. this.requestParam.data[3] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2580. pastureid: row.pastureid,
  2581. ftid: this.table2.getdataListParm.parammaps.ftid,
  2582. type: this.table2.getdataListParm.parammaps.fttypeid,
  2583. status: 1
  2584. }}
  2585. this.requestParam.data[4] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2586. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2587. id: this.table2.getdataListParm.parammaps.ftid
  2588. }}
  2589. }
  2590. const url = 'authdata/ftdetail/edit'
  2591. const data = this.requestParam
  2592. postJson(url, data).then(response => {
  2593. if (response.msg !== 'fail') {
  2594. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2595. this.getList2()
  2596. this.getList3()
  2597. } else {
  2598. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2599. }
  2600. })
  2601. // ExecDataByConfig(this.requestParam).then(response => {
  2602. // console.log('新增保存发送参数', this.requestParam)
  2603. // if (response.msg === 'fail') {
  2604. // this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2605. // } else {
  2606. // this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2607. // this.getList2()
  2608. // this.getList3()
  2609. // }
  2610. // })
  2611. }).catch(() => {
  2612. this.$message({ type: 'info', message: '已取消删除' })
  2613. })
  2614. },
  2615. handleSelectionChange2(val) {
  2616. console.log('勾选数据', val)
  2617. this.selectList2 = val
  2618. },
  2619. celldblclick(row, column, cell, event) {
  2620. console.log(row, '=====')
  2621. this.handleUpdate2(row)
  2622. },
  2623. handleDelete2() {
  2624. console.log('点击了删除')
  2625. if (this.selectList2.length == 0) {
  2626. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2627. } else {
  2628. MessageBox.confirm('是否确认删除此信息?', {
  2629. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2630. }).then(() => {
  2631. console.log(this.table2.list.length - this.selectList2.length)
  2632. if (this.table2.list.length - this.selectList2.length > 0) {
  2633. this.requestParam.common = { 'returnmap': '0' }
  2634. this.requestParam.data = []
  2635. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2636. this.requestParam.data[0].children = []
  2637. this.requestParam.data[0].children[0] = { 'name': 'insertFitHistory', 'type': 'e', 'parammaps': {
  2638. pastureid: '@insertSpotList.pastureid',
  2639. ftid: '@insertSpotList.ftid',
  2640. weight: 0,
  2641. preftid: '@insertSpotList.preftid',
  2642. dateTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}'),
  2643. slid: '@insertSpotList.id',
  2644. fid: '@insertSpotList.fid'
  2645. }}
  2646. this.requestParam.data[0].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2647. id: '@insertSpotList.id',
  2648. pastureid: '@insertSpotList.pastureid'
  2649. }}
  2650. this.requestParam.data[1] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2651. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2652. id: this.table2.getdataListParm.parammaps.ftid
  2653. }}
  2654. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2655. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2656. ftid:this.table2.getdataListParm.parammaps.ftid,
  2657. type: this.table2.getdataListParm.parammaps.fttypeid,
  2658. status: 1
  2659. }}
  2660. } else {
  2661. this.requestParam.common = { 'returnmap': '0' }
  2662. this.requestParam.data = []
  2663. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2664. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2665. id: this.table2.getdataListParm.parammaps.ftid
  2666. }}
  2667. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2668. this.requestParam.data[1].children = []
  2669. this.requestParam.data[1].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2670. id: '@insertSpotList.id',
  2671. pastureid: '@insertSpotList.pastureid'
  2672. }}
  2673. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2674. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2675. id: this.table2.getdataListParm.parammaps.ftid
  2676. }}
  2677. this.requestParam.data[3] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2678. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2679. ftid:this.table2.getdataListParm.parammaps.ftid,
  2680. type: this.table2.getdataListParm.parammaps.fttypeid,
  2681. status: 1
  2682. }}
  2683. }
  2684. const url = 'authdata/ftdetail/edit'
  2685. const data = this.requestParam
  2686. postJson(url, data).then(response => {
  2687. if (response.msg !== 'fail') {
  2688. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2689. this.getList2()
  2690. this.getList3()
  2691. } else {
  2692. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2693. }
  2694. })
  2695. // ExecDataByConfig(this.requestParam).then(response => {
  2696. // console.log('删除保存发送参数', this.requestParam)
  2697. // if (response.msg === 'fail') {
  2698. // this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2699. // } else {
  2700. // this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2701. // this.getList2()
  2702. // this.getList3()
  2703. // }
  2704. // })
  2705. })
  2706. }
  2707. },
  2708. // 拆分预混料
  2709. handleSplitPremix(row) {
  2710. console.log('点击了拆分预混料')
  2711. MessageBox.confirm('是否确认拆分当前预混料?', {
  2712. confirmButtonText: '确认',
  2713. cancelButtonText: '取消',
  2714. type: 'warning'
  2715. }).then(() => {
  2716. this.requestParam.name = 'splitFTpre'
  2717. this.requestParam.parammaps = {}
  2718. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2719. this.requestParam.parammaps.preftid = row.preftid
  2720. this.requestParam.parammaps.ftdid = row.id
  2721. this.requestParam.parammaps.pastureid = row.pastureid
  2722. this.requestParam.parammaps.feedgroup = row.feedgroup
  2723. this.requestParam.parammaps.sort = row.sort
  2724. this.requestParam.parammaps.fweight = row.fweight
  2725. PostDataByName(this.requestParam).then(response => {
  2726. if (response.msg === 'fail') {
  2727. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2728. } else {
  2729. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2730. this.getList2()
  2731. this.getList3()
  2732. }
  2733. })
  2734. }).catch(() => {
  2735. this.$message({
  2736. type: 'info',
  2737. message: '已取消删除'
  2738. })
  2739. })
  2740. },
  2741. // 合成预混料
  2742. handleSyntheticPremix() {
  2743. console.log('点击了合成预混料', this.selectList2)
  2744. this.dialogFull = false
  2745. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2746. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2747. return false
  2748. } else {
  2749. if (this.selectList2.length > 1) {
  2750. for (let i = 0; i < this.selectList2.length; i++) {
  2751. if (parseInt(this.selectList2[i].preftid) > 0) {
  2752. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2753. return false
  2754. }
  2755. }
  2756. if (this.selectList2[0].splitftpreid !== undefined) {
  2757. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2758. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2759. GetDataByName(this.detail.getdataListParm).then(response => {
  2760. if (response.data.list !== null) { // 不为空时得到比对数据
  2761. this.detail.list3 = response.data.list
  2762. const sortList = [] // 声明排序数组
  2763. var fweightSum = 0 // 总重量
  2764. for (let i = 0; i < this.selectList2.length; i++) {
  2765. const obj = {}
  2766. obj.fid = this.selectList2[i].fid
  2767. obj.fweight = this.selectList2[i].fweight
  2768. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2769. sortList.push(obj)
  2770. }
  2771. // 排序
  2772. sortList.sort(function(a, b) {
  2773. return a.fid.localeCompare(b.fid)
  2774. })
  2775. var a = 0
  2776. if (this.detail.list3.length == sortList.length) {
  2777. for (let i = 0; i < this.detail.list3.length; i++) {
  2778. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(3) == (sortList[i].fweight / fweightSum).toFixed(3)) {
  2779. a++
  2780. }
  2781. }
  2782. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2783. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2784. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2785. GetDataByName(this.detail.getdataListParm2).then(response => {
  2786. if (response.data.list !== null) {
  2787. this.detail.dialogStatus = 'SyntheticPremix'
  2788. this.detail.dialogFormVisible = true
  2789. this.detail.list = this.selectList2
  2790. this.detail.list2 = response.data.list
  2791. this.detail.disabled = true
  2792. setTimeout(() => {
  2793. this.detail.listLoading = false
  2794. }, 100)
  2795. } else {
  2796. this.detail.list2 = []
  2797. }
  2798. })
  2799. } else {
  2800. this.detail.dialogStatus = 'SyntheticPremix'
  2801. this.detail.dialogFormVisible = true
  2802. this.detail.list = this.selectList2
  2803. this.detail.disabled = false
  2804. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2805. setTimeout(() => {
  2806. this.detail.listLoading = false
  2807. }, 100)
  2808. }
  2809. } else {
  2810. this.detail.dialogStatus = 'SyntheticPremix'
  2811. this.detail.dialogFormVisible = true
  2812. this.detail.list = this.selectList2
  2813. this.detail.disabled = false
  2814. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2815. setTimeout(() => {
  2816. this.detail.listLoading = false
  2817. }, 100)
  2818. }
  2819. } else {
  2820. this.detail.list3 = []
  2821. this.detail.dialogStatus = 'SyntheticPremix'
  2822. this.detail.dialogFormVisible = true
  2823. this.detail.list = this.selectList2
  2824. this.detail.disabled = false
  2825. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2826. setTimeout(() => {
  2827. this.detail.listLoading = false
  2828. }, 100)
  2829. }
  2830. })
  2831. } else {
  2832. this.detail.dialogStatus = 'SyntheticPremix'
  2833. this.detail.dialogFormVisible = true
  2834. this.detail.list = this.selectList2
  2835. this.detail.disabled = false
  2836. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2837. setTimeout(() => {
  2838. this.detail.listLoading = false
  2839. }, 100)
  2840. }
  2841. } else {
  2842. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2843. return false
  2844. }
  2845. }
  2846. },
  2847. // 畜生类别
  2848. changeLivestockType2(item) {
  2849. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2850. },
  2851. syntheticPremixData() {
  2852. console.log('点击了合成预混料确认')
  2853. if (this.detail.disabled == true) { // 原预混料
  2854. let sumFweight = 0
  2855. for (let i = 0; i < this.detail.list.length; i++) {
  2856. sumFweight += parseFloat(this.detail.list[i].fweight)
  2857. }
  2858. sumFweight = sumFweight.toFixed(3)
  2859. this.isokDisable = true
  2860. setTimeout(() => {
  2861. this.isokDisable = false
  2862. }, 1000)
  2863. this.requestParam.common = { 'returnmap': '0' }
  2864. this.requestParam.data = []
  2865. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2866. this.requestParam.data[0].children = []
  2867. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2868. pastureid: '@insertSpotList.pastureid',
  2869. id: '@insertSpotList.id'
  2870. }}
  2871. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2872. this.requestParam.data[1].children = []
  2873. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2874. pastureid: Cookies.get('pastureid'),
  2875. ftid: this.table2.getdataListParm.parammaps.ftid,
  2876. fid: this.detail.list2[0].id,
  2877. fname: '@insertSpotList2.tname',
  2878. fweight: sumFweight,
  2879. islockcount: '0',
  2880. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2881. feedgroup: '@insertSpotList2.tname',
  2882. preftid: this.detail.list2[0].id,
  2883. autosecond: this.detail.list[0].autosecond
  2884. }}
  2885. ExecDataByConfig(this.requestParam).then(response => {
  2886. console.log('合成预混料保存发送参数', this.requestParam)
  2887. if (response.msg === 'fail') {
  2888. const tname = new RegExp("key 'tname'")
  2889. if (tname.test(response.data)) {
  2890. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2891. } else {
  2892. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2893. }
  2894. } else {
  2895. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2896. this.detail.dialogFormVisible = false
  2897. this.getList3()
  2898. this.getList2()
  2899. this.getDownList()
  2900. }
  2901. })
  2902. } else { // 现生成预混料
  2903. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2904. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2905. return false
  2906. } else if (this.detail.list2[0].tname == '') {
  2907. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2908. return false
  2909. } else if (this.detail.list2[0].ccid == '') {
  2910. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2911. return false
  2912. }
  2913. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2914. if (pattern.test(this.detail.list2[0].tname)) {
  2915. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2916. return false
  2917. }
  2918. let sumFweight = 0
  2919. for (let i = 0; i < this.detail.list.length; i++) {
  2920. sumFweight += parseFloat(this.detail.list[i].fweight)
  2921. }
  2922. sumFweight = sumFweight.toFixed(3)
  2923. console.log(sumFweight)
  2924. this.isokDisable = true
  2925. setTimeout(() => {
  2926. this.isokDisable = false
  2927. }, 1000)
  2928. if (this.detail.list2[0].tcolor == null) {
  2929. this.detail.list2[0].tcolor = '#CCCCCC'
  2930. }
  2931. this.requestParam.common = { 'returnmap': '0' }
  2932. this.requestParam.data = []
  2933. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2934. pastureid: Cookies.get('pastureid'),
  2935. tcode: this.detail.list2[0].tcode,
  2936. tname: this.detail.list2[0].tname,
  2937. tcolor: this.detail.list2[0].tcolor,
  2938. ccid: this.detail.list2[0].ccid,
  2939. ccname: this.detail.list2[0].ccname,
  2940. fttype: this.detail.list2[0].fttype,
  2941. fttypeid: this.detail.list2[0].fttypeid,
  2942. source: this.detail.list2[0].source,
  2943. remark: this.detail.list2[0].remark,
  2944. enable: this.detail.list2[0].enable
  2945. }}
  2946. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2947. this.requestParam.data[1].children = []
  2948. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2949. pastureid: '@insertSpotList.pastureid',
  2950. ftid: '@insertFT.LastInsertId',
  2951. fid: '@insertSpotList.fid',
  2952. fname: '@insertSpotList.fname',
  2953. fweight: '@insertSpotList.fweight',
  2954. islockcount: '@insertSpotList.islockcount',
  2955. sort: '@insertSpotList.sort',
  2956. feedgroup: '@insertSpotList.feedgroup',
  2957. preftid: '@insertSpotList.preftid',
  2958. autosecond: '@insertSpotList.autosecond'
  2959. }}
  2960. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2961. pastureid: '@insertSpotList.pastureid',
  2962. id: '@insertSpotList.id'
  2963. }}
  2964. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2965. this.requestParam.data[2].children = []
  2966. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2967. pastureid: Cookies.get('pastureid'),
  2968. ftid: this.table2.getdataListParm.parammaps.ftid,
  2969. fid: '@insertFT.LastInsertId',
  2970. fname: '@insertSpotList2.tname',
  2971. fweight: sumFweight,
  2972. islockcount: '0',
  2973. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2974. feedgroup: '@insertSpotList2.tname',
  2975. preftid: '@insertFT.LastInsertId',
  2976. autosecond: this.detail.list[0].autosecond
  2977. }}
  2978. ExecDataByConfig(this.requestParam).then(response => {
  2979. console.log('合成预混料保存发送参数', this.requestParam)
  2980. if (response.msg === 'fail') {
  2981. const tname = new RegExp("key 'tname'")
  2982. if (tname.test(response.data)) {
  2983. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2984. } else {
  2985. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2986. }
  2987. } else {
  2988. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2989. this.detail.dialogFormVisible = false
  2990. this.getList3()
  2991. this.getList2()
  2992. this.getDownList()
  2993. }
  2994. })
  2995. }
  2996. },
  2997. handleFormulationEvaluation(row) {
  2998. console.log(row)
  2999. // this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  3000. this.$router.push({
  3001. name: 'FormulationEvaluation',
  3002. params: {
  3003. tname: row.tname,
  3004. ftid: row.id,
  3005. pastureid: row.pastureid,
  3006. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  3007. inputDatetime: [new Date('startTime'), new Date('startTime')], // 日期后台待传
  3008. stopTime: parseTime(new Date(), '{y}-{m}-{d}')
  3009. }
  3010. })
  3011. },
  3012. // 配方记录
  3013. handleRowRecipeRecord(row) {
  3014. console.log(row)
  3015. this.rowRecipeRecord.temp = Object.assign({}, row)
  3016. this.rowRecipeRecord.dialogFormVisible = true
  3017. this.textMap.rowRecipeRecordTxt = '配方修改记录——配方:' + row.tname
  3018. this.rowRecipeRecord.dialogStatus = 'rowRecipeRecordTxt'
  3019. this.rowRecipeRecord.getdataListParm.parammaps.pastureid = row.pastureid
  3020. this.rowRecipeRecord.getdataListParm.parammaps.fitid = row.id
  3021. this.rowRecipeRecord.getdataListParm.parammaps.inputDatetime = []
  3022. this.getRowRecipeRecordList()
  3023. },
  3024. getRowRecipeRecordList() {
  3025. this.rowRecipeRecord.listLoading = true
  3026. this.rowRecipeRecord.getdataListParm.parammaps.fitid = this.rowRecipeRecord.temp.id
  3027. if (this.rowRecipeRecord.getdataListParm.parammaps.inputDatetime == null) {
  3028. this.rowRecipeRecord.getdataListParm.parammaps.inputDatetime = ''
  3029. this.rowRecipeRecord.getdataListParm.parammaps.startTime = ''
  3030. this.rowRecipeRecord.getdataListParm.parammaps.stopTime = ''
  3031. } else {
  3032. this.rowRecipeRecord.getdataListParm.parammaps.startTime = this.rowRecipeRecord.getdataListParm.parammaps.inputDatetime[0]
  3033. this.rowRecipeRecord.getdataListParm.parammaps.stopTime = this.rowRecipeRecord.getdataListParm.parammaps.inputDatetime[1]
  3034. }
  3035. const url = 'authdata/GetArrList'
  3036. const data = this.rowRecipeRecord.getdataListParm
  3037. postJson(url, data).then(response => {
  3038. if (response.data.list !== null) {
  3039. for (let i = 0; i < response.data.list.length; i++) {
  3040. if (response.data.list[i].arrList == null) {
  3041. this.$set(response.data.list[i], 'arrList', [])
  3042. }
  3043. }
  3044. this.rowRecipeRecord.list = response.data.list
  3045. this.rowRecipeRecord.pageNum = response.data.pageNum
  3046. this.rowRecipeRecord.pageSize = response.data.pageSize
  3047. this.rowRecipeRecord.total = response.data.total
  3048. } else {
  3049. this.rowRecipeRecord.list = []
  3050. this.rowRecipeRecord.total = 0
  3051. }
  3052. console.log(response.data, 'response.data')
  3053. setTimeout(() => {
  3054. this.rowRecipeRecord.listLoading = false
  3055. }, 100)
  3056. })
  3057. },
  3058. handleRowRecipeRecordSearch() {
  3059. this.getRowRecipeRecordList()
  3060. },
  3061. handleEnlarge() {
  3062. var height = (document.documentElement.clientHeight - 165 + 50).toString() + 'px'
  3063. // var height = (document.documentElement.clientHeight - 165 + 80).toString() + 'px'
  3064. // var height2 = '-' + (document.documentElement.clientHeight - 400).toString() + 'px'
  3065. var height2 = '-' + (this.$refs.template.offsetHeight).toString() + 'px'
  3066. // console.log(this.$refs.detail.offsetHeight)
  3067. // console.log(height2, 'height2')
  3068. this.isEnlarge = false
  3069. this.$refs.detail.style.top = height2
  3070. this.$refs.detail.style.height = height
  3071. this.$refs.appContainer.style.height = height
  3072. this.$refs.table2.style.height = 0
  3073. this.$refs.myContainer.style.posiiton = 'relative'
  3074. this.$refs.detail.style.posiiton = 'absolute'
  3075. },
  3076. handleNarrow() {
  3077. this.isEnlarge = true
  3078. this.$refs.detail.style.top = 0
  3079. this.$refs.detail.style.height = '300px'
  3080. this.$refs.myContainer.style.posiiton = ''
  3081. this.$refs.detail.style.posiiton = ''
  3082. this.$refs.detail.style.zIndex = ''
  3083. },
  3084. handleTakeEffect() {
  3085. if (this.selectList.length == 0) {
  3086. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  3087. } else {
  3088. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否生效?', {
  3089. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  3090. }).then(() => {
  3091. let ids = []
  3092. for (let i = 0; i < this.selectList.length; i++) {
  3093. ids.push(this.selectList[i].id)
  3094. }
  3095. var data = {}
  3096. data.parammaps = {}
  3097. data.parammaps.enable = 1
  3098. data.parammaps.id = ids.toString()
  3099. var url = 'authdata/feedtemplet/enable'
  3100. postJson(url,data).then(response => {
  3101. console.log('生效保存发送参数', data)
  3102. if (response.msg === 'fail') {
  3103. this.$notify({ title: '生效失败', message: response.data, type: 'warning', duration: 2000 })
  3104. } else {
  3105. this.$notify({ title: '', message: '生效成功', type: 'success', duration: 2000 })
  3106. this.getList()
  3107. }
  3108. })
  3109. })
  3110. }
  3111. },
  3112. handleDisable() {
  3113. if (this.selectList.length == 0) {
  3114. this.$message({ type: 'error', message: '请选择车次信息', duration: 2000 })
  3115. } else {
  3116. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否禁用?', {
  3117. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  3118. }).then(() => {
  3119. let ids = []
  3120. for (let i = 0; i < this.selectList.length; i++) {
  3121. ids.push(this.selectList[i].id)
  3122. }
  3123. var data = {}
  3124. data.parammaps = {}
  3125. data.parammaps.enable = 0
  3126. data.parammaps.id = ids.toString()
  3127. console.log('禁用', data)
  3128. var url = 'authdata/feedtemplet/enable'
  3129. postJson(url,data).then(response => {
  3130. console.log('禁用保存发送参数', this.requestParam)
  3131. if (response.msg === 'fail') {
  3132. this.$notify({ title: '禁用失败', message: response.data, type: 'warning', duration: 2000 })
  3133. } else {
  3134. this.$notify({ title: '', message: '禁用成功', type: 'success', duration: 2000 })
  3135. this.getList()
  3136. }
  3137. })
  3138. })
  3139. }
  3140. }
  3141. }
  3142. }
  3143. </script>
  3144. <style lang="scss" scoped>
  3145. // .search{margin-top:10px;height: 40px;}
  3146. // .operation{height: 50px;}
  3147. .table{margin-top:5px;}
  3148. .table2{margin-top:10px;}
  3149. $width:350px;
  3150. $left:325px;
  3151. .selectInput{
  3152. position: relative;
  3153. display: inline-block;
  3154. .Input{width: $width;position: relative;}
  3155. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  3156. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  3157. .selectUl{
  3158. height:220px;overflow-y: auto;z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  3159. li{
  3160. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  3161. a{float:left;width: 80px;}
  3162. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  3163. }
  3164. }
  3165. }
  3166. .template{
  3167. background: #fff;
  3168. position: relative;
  3169. }
  3170. .app-container{background: #fff;}
  3171. .detail{
  3172. background: #fff;
  3173. overflow-y: hidden;
  3174. overflow-x: hidden;
  3175. // position: fixed;
  3176. // bottom: 0;
  3177. // right:0;
  3178. z-index: 3;
  3179. // width: calc(100% - 210px);
  3180. position: relative;
  3181. }
  3182. .hide2{float: right;right:0;}
  3183. .templateDialog{
  3184. background: #fff;
  3185. position: relative;
  3186. }
  3187. .detailDialog{
  3188. background: #fff;
  3189. position: relative;
  3190. }
  3191. .hide{float: right;margin-right: 60px;}
  3192. </style>
  3193. <style>
  3194. .el-color-dropdown__main-wrapper{display: none !important;}
  3195. .el-color-dropdown__value{display: none !important;}
  3196. .el-color-dropdown__btns .el-button--text{display: none !important;}
  3197. </style>