81f9d534372d38532cba432b010ef2d0bff4ff0e.svn-base 100 KB

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