428fcf630d7b565df8e31622acb3f901dc3c70fc.svn-base 125 KB

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