2fe233c2598e2c0d971723b18b9ab49343c9c4b6.svn-base 128 KB

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