43ad25834911571166085d8dbbc86d3ed0e5374c.svn-base 120 KB

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