c156fc89709e87ae30490c63d106a6ab0db6c2f3.svn-base 121 KB

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